Remove/Redirect index.php from url to prevent duplicate urls

后端 未结 5 1909
盖世英雄少女心
盖世英雄少女心 2021-01-03 09:56

Please read the question carefully before marking as duplicate.

We all know, that using in .htaccess:

RewriteCond %{REQUEST_FIL         


        
5条回答
  •  春和景丽
    2021-01-03 10:33

    Insert these rules just below RewriteEngine On line:

    RewriteCond %{THE_REQUEST} /index\.php [NC]
    RewriteRule ^(.*?)index\.php[^/] /$1? [L,R=302,NC,NE]
    
    RewriteCond %{THE_REQUEST} /index\.php [NC]
    RewriteRule ^(.*?)index\.php(?:/(.*))?$ /$1$2? [L,R=302,NC,NE]
    

提交回复
热议问题