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.

2 Answers 2

6

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

1
1

For a .htaccess file:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.