【发布时间】:2013-05-30 07:17:43
【问题描述】:
我正在尝试在 .htaccess 中创建对 SEO 友好的屏蔽重写。 htaccess 文件在 localhost 和我的个人服务器上运行良好,但不幸的是在 GoDaddy 的服务器上似乎无法运行。我知道这已经是一个问题,但是为一个打算使用 Godaddy 作为他们的主机的客户工作。
问题是重写似乎强制重定向在浏览器 URL 栏中显示重写的查询字符串,而不是将其保留在内部。 例如。
规则:
RewriteRule ^/?([a-zA-Z0-9-_/]*)$ /index.php?loadPage=$1&mode=cms [L,QSA]
链接:/images 重定向到/images/?loadPage=images&mode=cms
对于浏览器,这个“应该”保留为/images/。我在下面复制了我的简短.htaccess,为开发块修改了 IP
<Files .htaccess>
deny from all
</Files>
Options -MultiViews +FollowSymlinks -Indexes
RewriteEngine On
RewriteBase /
# Stop Old redirection from block below
RewriteCond %{REQUEST_URI} "/old/"
RewriteRule (.*) $1 [L]
# Under construction Redirect
RewriteCond %{REMOTE_ADDR} !^0.0.0.0
RewriteCond %{REQUEST_URI} !^/?old/
RewriteRule ^/?(.*) “/old/$1″ [L,QSA]
#Admin utilities rewrite
RewriteRule ^/?admin/?(.*)$ /index.php?loadPage=$1&mode=backend [L,QSA]
#CMS/Frontend rewrites -- this one is failing
RewriteRule ^\/?([a-zA-Z0-9-_]+)\/?$ /index.php?loadPage=$1&mode=cms [QSA,L]
一个潜在的提示是显示的 url 是 /images/?query_string,而不是 index.php?query_string,因此它没有进行完全重定向,尽管外部请求从页面请求收到 301 响应。
【问题讨论】:
-
感谢您提供的链接,不幸的是,我对它们都进行了调查,但似乎都不适用于我的情况。
标签: php .htaccess redirect mod-rewrite