虽然我们已将index.php
重定向到root,但仍然会在以下4个版本中获取内页网址:
https://example.com/articles [/index.php/articles, /index.php?/articles & /?/articles]
有人会解释原因吗?
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{http_host} ^www.example.com
RewriteRule ^(.*) example.com/$1 [L,R=301]
RewriteCond $1 !^(index\.php|phpinfo\.php|Charts|assets|uploads|userfiles|customer-uploads|application|sitemap\.xml|sitemap\.html|robots\.txt|gyan\.rss)
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
答案 0 :(得分:0)
尝试使用这种更简单的方法
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php| (.*)\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]