views:

22

answers:

1

Ok, this should be simple, but I'm having a fair amount of trouble with it. Basically, I'm trying to rewrite http://server.com/ to http://server.com/homepage, but I only want it to rewrite it internally--the user should never see the /homepage URL. I tried this:

RewriteRule ^$ /homepage [L]

And it properly matches the URL, but it issues a 301 redirect instead of just handling it internally--the user is redirected to http://server.com/homepage. How do I change that?

I feel like this is something pretty simple, and I'm completely missing it, so hopefully someone out there can help!

+1  A: 

Assuming homepage is a directory, try this instead:

RewriteRule ^$ /homepage/

I forget exactly what's at play here, so hopefully that'll fix the problem (it works for me), then I'll update my answer with an explanation of what's going on, for the sake of completeness.

Edit: Ah right, it's mod_dir and its DirectorySlash option trying to clean up the URL's missing trailing slash. If you don't have the trailing slash, the DirectoryIndex handler isn't invoked, and since mod_rewrite just rewrites the URL before this processing happens and DirectorySlash is, by default, set to On, mod_dir performs a redirect to the slash-completed URL.

Tim Stone
And it works! Thank you!
Kyle Slattery