sadams101 Posted February 16, 2022 Share Posted February 16, 2022 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 More sharing options...
Ryan Ashbrook Posted February 16, 2022 Share Posted February 16, 2022 This line is likely the problem: RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html) [NC] Try this instead (note I have not tested): RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html)$ [NC] Link to comment Share on other sites More sharing options...
sadams101 Posted February 16, 2022 Author Share Posted February 16, 2022 Unfortunately it doesn't do the redirect. Link to comment Share on other sites More sharing options...
IveLeft... Posted February 16, 2022 Share Posted February 16, 2022 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] sadams101 1 Link to comment Share on other sites More sharing options...
sadams101 Posted February 16, 2022 Author Share Posted February 16, 2022 (edited) I spoke to soon, and edited my response...for some reason it isn't redirecting, and stays on the /index.php Edited February 16, 2022 by sadams101 Link to comment Share on other sites More sharing options...
sadams101 Posted February 17, 2022 Author Share Posted February 17, 2022 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 More sharing options...
Recommended Posts