【发布时间】:2015-04-17 00:18:21
【问题描述】:
我有一个现有的站点,其 URL 中有 php 被编入索引。我想将 URL 更改为不包含 PHP,因此 page.php 将被重写为 http://example.com/thepage
重写工作正常,但是当我尝试使用 page.php 访问页面时,重定向会导致“页面无法在循环中显示”错误
我需要弄清楚如何设置重定向并重写 URL,因为 Google 现在已将 PHP URL 和漂亮 URL 编入索引。
我在网上看了无数页,但找不到答案。
请帮忙。
这是我的 htaccess
# The redirect below caused a loop when I access the page as
# http://example.com/thepage.php
# Moving the redirect after the rewrite didn't work either.
Redirect 301 /thepage.php http://example.com/thepage
RewriteEngine on
# Rewrite works. The page does display corectly for this link
# http://example.com/thepage
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
# RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
#RewriteRule ^photos([^\.]+)$ photos [NC,L]
RewriteRule ^([^\.]+)$ $1.php [NC,L]
</IfModule>
ErrorDocument 404 http://example.com/
谢谢
【问题讨论】:
标签: .htaccess mod-rewrite redirect