Page 1 of 1

How to redirect indexed pages that include index.php in the url to the url without it

Posted: Thu Aug 11, 2022 2:04 pm
by RobinClapp
Hi, I am inheriting a large site that is fully indexed. And all the pages have index.php in the url.

sitename.com/index.php
sitename.com/index.php/nationalnews.html

I know how to remove the index.php by enabling URL rewriting and changing to .htaccess

My question is, is there a way to permanently redirect all traffic from sitename.com/index.php to sitename.com? Including all other urls also, sitename.com/index.php/nationalnews.html to sitename.com/nationalnews.html?

Re: How to redirect indexed pages that include index.php in the url to the url without it

Posted: Thu Aug 11, 2022 7:43 pm
by Webdongle
Enable the Redirect plugin and select the 'Collect URLs' option. Then use the redirect component to redirect each one.
Or us the .htaccess try
Redirect *.html http://yoursite.com/

Re: How to redirect indexed pages that include index.php in the url to the url without it

Posted: Thu Aug 11, 2022 9:49 pm
by brian
RewriteEngine On
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]

Re: How to redirect indexed pages that include index.php in the url to the url without it

Posted: Fri Aug 12, 2022 2:04 pm
by RobinClapp
Thank you so much!

Re: How to redirect indexed pages that include index.php in the url to the url without it

Posted: Wed Mar 01, 2023 1:54 pm
by mojito
Brians solution works on the frontend but breaks the backend for me. Anyone else? I am looking for a way to not alter admin style urls so they still work. TY

Re: How to redirect indexed pages that include index.php in the url to the url without it

Posted: Wed Mar 01, 2023 4:31 pm
by mojito
This seems to work so far

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/administrator
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^index(.*) / [R=301,L]