views:

117

answers:

2

I have a website with a for example (http://example.com). I want any requests for / i.e. http://example.com to be redirected to http://example.com/stuff. I added a .htaccess file with the following line:

redirect 301 / http://example.com/stuff

Any suggestion?

+1  A: 

Redirect directs anything that starts with the pattern given.

Use:

RedirectMatch 301 ^/$ http://example.com/stuff

This takes a regular expression, so you can make it more specific.

rjmunro
+3  A: 

See the Redirect directive's documentation:

Then any request beginning with URL-Path will return a redirect request to the client at the location of the target URL. Additional path information beyond the matched URL-Path will be appended to the target URL.

Use a RedirectMatch instead:

RedirectMatch 301 ^/$ http://example.com/stuff
David Schmitt
Even with this I am still getting a redirect loop.
Johan
Use "wget -S" to debug this. Browsers might cache the redirect.
David Schmitt
Thanks. I've recently started using chrome and somehow its just doesn't reload on F5. I had to clear the cache manually.
Johan