Jump to content

Mod Rewrite for index.php Causing Errors


Recommended Posts

I am wondering why this simple mod rewrite to eliminate a duplicate home page is causing errors:

# Remove index.php from root URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html) [NC]
RewriteRule ^index\.php$ https://www.mysite.com/ [R=301,L]

Quote

The link could not be embedded because of an unexpected error: error: "The CSRF protection key did not match. This may indicate a plugin or theme is out of date. Please contact technical support for more information.".


 

Link to comment
Share on other sites

33 minutes ago, sadams101 said:

I am wondering why this simple mod rewrite to eliminate a duplicate home page is causing errors:

# Remove index.php from root URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html) [NC]
RewriteRule ^index\.php$ https://www.mysite.com/ [R=301,L]


 

Try this

#Remove index.php|html at the end of the URL and change to /
RewriteCond %{THE_REQUEST} ^GET\ /.*/index\.(php|html)\ HTTP
RewriteRule (.*)index\.(php|html)$ /$1 [R=301,L]

 

Link to comment
Share on other sites

In the end it may not matter, as I do know that there is a canonical link to my base URL from the /index.php version, however, to be SEO technically correct there really should be a 301 redirect as well. So far I've not found a way to make this work that doesn't create issues.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...