tags:

views:

17

answers:

1

I am running a website on MAMP, and the root is http://localhost/sandbox

When I have links that link to, for example - /calendar

it directs them to localhost/calendar, I want it to redirect to localhost/sandbox/calendar

What would I have to do in htaccess to get it to redirect everything to localhost/sandbox/ as the root?

+2  A: 

You would usually change the application or site that generates the links, and have that add the /sandbox to the URL.

If that's not possible, putting this into the web root directory (the one above /sandbox) should do:

RewriteEngine on
Options +FollowSymlinks

RewriteCond  %{REQUEST_URI} !^/sandbox  # If URL does not start with /sandbox... 
RewriteRule (.*) /sandbox/$1            # Add /sandbox/ in front of it

(if it's easier to achieve with Alias, Apache Gurus, feel free to add your solution, but I couldn't get Alias to work for this scenario.)

However, this solution will make any other directory besides /sandbox inaccessible. You may want to re-think your Virtual hosts structure!

Pekka
Thanks! Did the trick, this will do for now.
Brad