我有几个重写规则在我的.htaccess似乎是冲突。如何解决冲突的mod_rewrite规则和条件
我正在运行ExpressionEngine(CodeIgniter)网站,该网站使用index.php文件解析所有URI。出于美学原因,我从URI中删除了index.php。
我想实现:
- 重定向301以斜杠(example.com/bla/ =>
example.com/bla) - 删除的index.php从所有页面所有的URI
我现在拥有的一切:
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{SERVER_ADDR} !=127.0.0.1
RewriteCond %{SERVER_ADDR} !=::1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteRule^http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond $1 !^(images|system|themes|index\.php|admin\.php|favicon\.ico|robots\.txt|humans\.txt|crossdomain\.xml) [NC]
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
</IfModule>
w ^帽子作品:
- 所有深层链接被重定向到非尾随斜线版本 (example.com/bla/ => example.com/bla)。
- index.php从所有深度链接页面中删除。
什么不起作用:
- 主页(example.com)给了我在谷歌浏览器的错误,说: “太多的重定向”。
如何更新的条件和规则,使我达到清洁环节没有结尾的斜线,没有的index.php,无论哪个页面是的。
如果用'RewriteRule ^(。+)/ $/$ 1 [L,R = 301]'替换'RewriteRule ^(。*)/ $/$ 1 [L,R = 301]'会怎样? –
转到config.php,然后更改$ config ['url_suffix'] =''; –