1

Using .htaccess, how can I rewrite the URL, such that when a visitor types:

http://www.domain.com/index.php
http://www.domain.com/index.html

they will be redirected to http://www.domain.com/.

I tried it with redirection, but it takes me in the loop...

Please if you could help me with this.

1 Answer 1

6
RewriteEngine On
RewriteRule ^index\.(php|html?)$ http://www.mydomain.com/ [R=301,L]
Sign up to request clarification or add additional context in comments.

2 Comments

What would the difference be if the flags were [NC,R,L] instead of [R=301,L]?
@JosiahSprague it would also match InDeX.pHp because of NC, and redirect with status code 302 instead of the desired 301.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.