【发布时间】:2011-02-21 03:27:03
【问题描述】:
我创建了一个 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
和
http://www.plugb.com/games/adventure-rpg
有没有办法重定向 index.php 网址?
谢谢你, 加布里埃尔。
【问题讨论】:
-
我没明白。您是否尝试从 URL 中删除 index.php?
标签: php .htaccess codeigniter