Reputation: 55
I have this rule for redirect from index.php
RewriteCond %{HTTP_HOST} ^(.*):443$ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^/index.php$ [NC]
RewriteRule ^(.*)index\.php$ https://%1/$1 [L,R=301]
But it works only for address: site.com/index.php to site.com I need to redirect from all adress who contain index.php, for example site.com/categories/rings/index.php to site.com/categories/rings/ Thanks!
Upvotes: 1
Views: 568
Reputation: 1
⭐ I use this in my .htaccess file in laravel project
# Redirect index.php to non index.php
RewriteRule ^(.+)/index.(php|html) /$1 [R=301,L]
RewriteRule ^/index.(php|html) / [R=301,L]
Upvotes: 0
Reputation: 12027
Your RewriteCond
rules are the problem:
RewriteRule ^(.*/)?index\.php$ https://%{HTTP_HOST}/$1 [L,R=301]
If you want to keep the port RewriteCond
, you can use this:
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*/)?index\.php$ https://%{HTTP_HOST}/$1 [L,R=301]
Upvotes: 1