Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a website set up on shared hosting like so...

I'd like to have the /cms folder hidden from the URL. I also need to manage redirects from the old folder structure - if that is necessary.



I ended up using this:

RewriteRule (.*) cms/$1 [L] from this doc

Added to settings.php for drupal

$base_url = '; // NO trailing slash!

Now just need to fix the redirects - the original pages come up, but retain the rewritten folder.

share|improve this question
Not an apache guru here but check into .htaccess files. I think those or simple permissions will achieve what you're after. – SpacemanSpiff Feb 8 '11 at 15:04

What you want to look into is mod_rewrite for Apache (often part of the default install).

You will then rewrite your URLs. For example:

#rewrite to
#add more rules or RewriteCond to account for old URLs you want to keep active.    
RewriteRule ^/(.*)  /cms/$1

You'll probably also want to do a search on drupal and pretty or clean urls which will give you more info on this and will also let you drop the index.php.

share|improve this answer

Try to enable mod_rewrite and to add a rewrite rule like this:

RewriteRule ^/?(.*)$ /cms/$1

Not sure about redirects, probably you should utilize mod_proxy to handle proper redirects.

share|improve this answer
mod_rewrite can't handle this with something like this? RewriteRule ^cms/(.*)$$1 [R=301,L] – Sam Feb 8 '11 at 17:54
@Sam careful doing that, you could end up in a redirect loop. – matthew Feb 8 '11 at 19:11
@Sam You should try to put RewriteRule ^cms/(.*)$$1 [R=301,L] before RewriteRule (.*) cms/$1 [L], it looks like it will work this way – Alex Feb 8 '11 at 19:16
that doesn't seem to be working - just leaves the url as is. I'm using WAMP(local dev server) with localhost as the domain name. – Sam Feb 8 '11 at 19:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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