سؤال

I want to redirect www.domainname.com/index.php to www.domainname.com.

RewriteCond %{THE_REQUEST} ^.*/index\.php 
RewriteRule ^(.*)index.php$ /$1 [R=301,L]

I used this code, but it redirects www.domainname.com/admin/index.php as well. However, I don't want to redirect www.domainname.com/admin/index.php.

How can I achieve that?

هل كانت مفيدة؟

المحلول

You can use this rule:

RewriteCond %{THE_REQUEST} \s/+index\.php 
RewriteRule ^index\.php$ / [R=301,L]
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top