0

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.

Sam
  • 2,020
  • 1
  • 16
  • 22
  • Not an apache guru here but check into .htaccess files. I think those or simple permissions will achieve what you're after. – SpacemanSpiff Feb 08 '11 at 15:04

2 Answers2

1

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.

matthew
  • 1,319
  • 1
  • 11
  • 21
1

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.

Alex
  • 7,939
  • 6
  • 38
  • 52
  • mod_rewrite can't handle this with something like this? RewriteRule ^cms/(.*)$ http://www.mysite.com/$1 [R=301,L] – Sam Feb 08 '11 at 17:54
  • @Sam careful doing that, you could end up in a redirect loop. – matthew Feb 08 '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 08 '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 08 '11 at 19:42