【发布时间】:2017-02-13 11:15:52
【问题描述】:
我有两种类型的网址:
http://www.example.com/?content=contact_form.php
和
http://www.example.com/?content=product.php&id=20
我像这样更改了我的整个 URL 系统:
http://www.example.com/file/contact_form
和
http://www.example.com/product/I-m-the-title/20
当然,我使用 .htaccess 进行了 301 重定向来告诉 Google 和公司。新网址。
我是这样设计的:
# Rewrite URLs
RewriteEngine On
RewriteRule ^(ignore)($|/) - [L]
RewriteRule ^file/([^/]*)$ /?content=$1.php [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /?content=$1.php&title=$2&id=$3 [L]
# Redirect old URL to new URL
RewriteCond %{QUERY_STRING} ^content=contact\_form\.php$
RewriteCond %{REQUEST_URI} ^\/$
RewriteRule .* http://www.example.com/file/contact_form? [R=301,L]
RewriteCond %{QUERY_STRING} ^content=product\.php&class=I-m-the-title$
RewriteCond %{REQUEST_URI} ^\/$
RewriteRule .* http://www.example.com/I-m-the-title/Test/20? [R=301,L]
我的问题:
它非常适合:http://www.example.com/?content=product.php&id=20
但是对于http://www.example.com/?content=contact_form.php,我收到的消息是由于重定向过多而无法打开它。
有人知道我做错了什么吗?我希望有人能尽快帮助我,因为我必须在 Google 误解它之前修复它。
【问题讨论】:
标签: php apache .htaccess redirect mod-rewrite