views:

218

answers:

2

Server: Apache

I'm looking to rewrite my urls in the following way, and I can't figure out a way to get it to work.

http://website.com/index.html

I want it to redirect to:

http://website.com/

So basically I want to load index.html, but not display it in the url. I also don't want to give it another name. I'm not looking for /index.html to become /index

Additionally, I'm trying to have any GET data such as:

http://website.com/index.html?id=0&name="fred"

To rewrite to:

http://website.com/?id=0&name="fred".

If you have a solution that is not using .htaccess files that's fine as well.

+4  A: 

I believe this should work:

RewriteEngine on
RewriteRule ^index\.html(.*)$ /$1 [R=permanent,L]

This will redirect any requests that start with /index.html to simply "/" and will preserve any arguments that come after index.html

OverloadUT
The starting slash definitely SHOULD NOT be there.
Piskvor
Thanks; I updated the answer
OverloadUT
+1  A: 

For a .htaccess file:

RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET\ /index\.html
RewriteRule ^index\.html$ / [L,R=301]
Gumbo