1

Due to request, every page (except the front page) needs to be prefixed with "training"; if the path was first /aboutus, now it needs to be /training/aboutus.

I edited almost every page I needed by rewriting mypage.tpl.php, so to change all path would be troublesome.

I tried to edit the .htaccess file, for example using the following rewrites.

RewriteRule ^/training/about$ /about
RewriteRule ^(.*)/training/about$ $1/about

Neither of them works.

Could someone point me to the right direction?

1
  • use pathauto, may work for this...
    – monymirza
    Apr 4, 2013 at 9:50

3 Answers 3

1

Using rewrite in .htaccess may change how external URLs are handled by Apache, but it won't change how Drupal generates URLs itself. For that you need to change the base URL. Take a look at https://stackoverflow.com/questions/5879190/how-to-set-the-base-url-in-drupal

0

Try this

 RewriteRule ^about-us$  [R=301,L]
1
  • Bonus point for the flags, but not valid syntax. You have to rewrite it to something
    – mc0e
    Dec 17, 2014 at 6:19
0

Rewrite rules in a .htaccess directory are interpreted relative to the directory where the .htaccess file is found (or relative to whatever the RewriteBase directive says, if there is one). It is not relative to the base of the site, so you may need to adapt advice you find on rewrite rules intended to be used from the apache configuration files.

I'm troubled by your saying you've gone through editing your template files. That's almost certainly wrong, and I'd encourage you to add detail so someone can set you straight on that. @Alfred Armstrong's answer is worth paying attention to there, but it might need more fleshing out.

However, to the extent that your question as posed is:

Due to request, every page (except the front page) needs to be prefixed with "training"; if the path was first /aboutus, now it needs to be /training /aboutus.

I figure what you want is something like:

RewriteCond %{REQUEST_URI} !^/(training|$)
RewriteRule ^training/(.*) $1 [R=301,L]

Note though that you should probably use R=302 at first while testing this, so the search engines will check back in again to see if the redirect has changed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.