我在我的网站中遇到了URL重定向的小问题。这是我的.htaccess文件:如果用户使用/index.php输入URL而URL中没有/index.php,我该如何重定向用户
RewriteEngine On
# Start –301 redirect for "http://" to "http://www"
Options +FollowSymLinks
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,L]
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /?(.*)/index\.php
RewriteRule ^(.*)$ /%1/ [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
这工作fine.All URL完美的作品,而不在它具有的index.php。
但我的问题是有人把一个URL与index.php
(例如https://example.com/index.php/test
)。所以它也会起作用。这是一个问题,我希望当用户将URL放在/index.php中时,它将重定向到同一页面,而不会有/index.php
。请帮我解决这个问题。
为什么用户会将“index.php”附加到URL中?即使他们这样做,为什么要打扰“修复”呢?通常只有黑客希望恶意URL。 – 2013-03-07 10:23:01
@TimS。这是创建一个问题,如果有人把一个url /index.php它将在谷歌标记为重复的网址。请帮助我,如果您有任何暗示 – Toretto 2013-03-07 10:24:34
不,它不会标记重复。如果您没有在包含'index.php'版本的网站中放置任何链接,那么Google抓取工具将不会为其编制索引。 – 2013-03-07 11:55:43