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

后端 未结 5 1870
盖世英雄少女心
盖世英雄少女心 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:48

    This solved my problem to force https & remove index.php from the url in Kohan 2.3

    RewriteEngine On
    
    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]
    
    
    RewriteRule ^(application|system) - [F,L]
    
    RewriteCond %{THE_REQUEST} /index.php [NC]
    RewriteRule ^(.*)index\.php$ /$1/ [R=301,L,NC,NE]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteRule .* index.php/$0 [PT,L]
    
    
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteCond %{HTTP_HOST} ^(?!localhost$|127\.0\.0\.1$)(?:www\.)?(.+)$ [NC]
    RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]
    

提交回复
热议问题