我创建了一个 CodeIgniter 应用程序,现在我尝试将带有 index.php 的 url 重定向到不带它的 url。
我当前的 .htaccess 是:
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,都可以访问同一页面。
例如:
http://www.plugb.com/index.php/games/adventure-rpg
and
http://www.plugb.com/games/adventure-rpg
有没有办法重定向index.php URL?
谢谢你,
加布里埃尔.
在最后一条规则之前添加以下内容:
RewriteBase /
RewriteCond %{HTTP_HOST} !=""
RewriteRule ^index.php(/.*)?$ http://%{HTTP_HOST}$1 [R=301]
或拒绝访问:
RewriteRule ^index.php(/.*)?$ - [R=404]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)