/index.php/,/index.php?/,/?/在codeigniter网址中

时间:2016-11-01 12:36:20

标签: apache .htaccess codeigniter mod-rewrite

虽然我们已将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|c‌​ustomer-uploads|appl‌​ication|sitemap\.xml‌​|sitemap\.html|robot‌​s\.txt|gyan\.rss) 
RewriteRule ^(.*)$ index.php?/$1 [QSA,L] 

1 个答案:

答案 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]