Skip to content

Redirecting index.html to /

Issue Description

Launching Stuart Wright we came across the issue where this line in htaccess

 

Redirect 301 /index.html https://www.stuartwrightfunerals.co.uk/

 

Was causing a redirect loop.

Affected Browsers

  • all

Issue Type

How to Fix the Issue

The reason why you are getting the infinity loop is that the your apache is tring to deliver the content of the file /index.htm when you accessing the root directory / because it’s part of the directory index list. Now your redirection takes effect (because you virtual accessing the page /index.htm) and the procedure starts from the beginning.

To solve your problem you should use a rewrite rule instead of a redirection. The rewrite rule only affects to the requested URL and doesn’t end in an infinity loop. The following rule should work in your case:

Fixed Code Snippets

RewriteEngine On
RewriteCond %{THE_REQUEST} \s/index\.htm
RewriteRule ^index.htm$ / [R=301,L]

References

Reference Description

Reference Link

Stackoverflow

Back to Issues List