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

http://www.mysite.com/cms/index.php

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.

Thanks


Update

I ended up using this:

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

Added to settings.php for drupal

$base_url = 'http://www.mysite.com; // NO trailing slash!

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

link|improve this question

80% accept rate
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
feedback

2 Answers

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 http://www.mysite.com/index.php to http://www.mysite.com/cms/index.php
#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.

link|improve this answer
feedback

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.

link|improve this answer
mod_rewrite can't handle this with something like this? RewriteRule ^cms/(.*)$ mysite.com/$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/(.*)$ mysite.com/$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
feedback

Your Answer

 
or
required, but never shown

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