重定向的index.php在codeIgniter [英] Redirect index.php in CodeIgniter
本文介绍了重定向的index.php在codeIgniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个codeIgniter应用程序,现在我想用重定向的index.php到URL网址离不开它了。
I created a CodeIgniter application and now I'm trying to redirect the urls with index.php to urls without it.
我目前的.htaccess是:
My current .htaccess is:
RewriteEngine On
RewriteBase /
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
# Enforce www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
RewriteRule ^(.*)$ http://www.plugb.com/$1 [L,R=301]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
唯一的问题是,在同一页访问具有和不具有的index.php
The only problem is that the same page is accessible with and without the index.php.
例如:
http://www.plugb.com/index.php/games/冒险RPG
和
http://www.plugb.com/games/adventure-rpg
有没有办法来重定向index.php的网址?
Is there a way to redirect the index.php URLs?
感谢您, 加布里埃尔。
Thank you, Gabriel.
推荐答案
在过去的规则之前,补充一点:
Add this before the last rule:
RewriteBase /
RewriteCond %{HTTP_HOST} !=""
RewriteRule ^index.php(/.*)?$ http://%{HTTP_HOST}$1 [R=301]
或拒绝访问:
or to deny access:
RewriteRule ^index.php(/.*)?$ - [R=404]
这篇关于重定向的index.php在codeIgniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文