Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php .htaccess;如果.htaccess中有两个不同的重定向,则重定向过多_Php_Apache_.htaccess_Redirect_Mod Rewrite - Fatal编程技术网

Php .htaccess;如果.htaccess中有两个不同的重定向,则重定向过多

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

我有两种类型的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]
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]