Php .htaccess;如果.htaccess中有两个不同的重定向,则重定向过多
我有两种类型的URL:Php .htaccess;如果.htaccess中有两个不同的重定向,则重定向过多,php,apache,.htaccess,redirect,mod-rewrite,Php,Apache,.htaccess,Redirect,Mod Rewrite,我有两种类型的URL: http://www.example.com/?content=contact_form.php 及 我改变了我的整个URL系统,如下所示: http://www.example.com/file/contact_form # Rewrite URLs RewriteEngine On RewriteRule ^(ignore)($|/) - [L] RewriteRule ^file/([^/]*)$ /?content=$1.php [L] RewriteRul
http://www.example.com/?content=contact_form.php
及
我改变了我的整个URL系统,如下所示:
http://www.example.com/file/contact_form
# 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]
及
当然,我用.htaccess
进行了301重定向,以告诉Google和co.新的URL
我是这样做的:
http://www.example.com/file/contact_form
# 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
我收到一条消息,由于重定向太多,无法打开它
有人知道我做错了什么吗?我希望任何人能尽快帮助我,因为我必须在谷歌误解它之前修复它。你的规则会导致无限循环,因为它会一次又一次地将你的uri重写到同一位置,覆盖你的内部和外部重定向。。要修复重写循环,请在htaccess的顶部添加以下内容
RewriteEngine on
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]