Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.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
.htaccess 301重定向与其他301重定向冲突_.htaccess_Redirect - Fatal编程技术网

.htaccess 301重定向与其他301重定向冲突

.htaccess 301重定向与其他301重定向冲突,.htaccess,redirect,.htaccess,Redirect,我遇到了重定向冲突,没有得到解决。 例如,我有以下重定向: redirect 301 http://www.example.com/mobile-cars http://www.example.com/cars/ redirect 301 http://www.example.com/mobile-cars/for-her http://www.example.com/cars-for-her/ redirect 301 http://www.example.com/mobile-cars/fo

我遇到了重定向冲突,没有得到解决。 例如,我有以下重定向:

redirect 301 http://www.example.com/mobile-cars http://www.example.com/cars/
redirect 301 http://www.example.com/mobile-cars/for-her http://www.example.com/cars-for-her/
redirect 301 http://www.example.com/mobile-cars/for-him http://www.example.com/cars-for-him/
redirect 301 /mobile-cars/for-her/kia-moto http://www.example.com/kia-12.html
第一个重定向和所有其他重定向冲突(我假设它是冲突的,因为第一个重定向总是其他域的一部分)。即使我摆脱了,只是尝试重定向查询,它也不起作用

是否有任何参数阻止使用重定向进行后续重定向或其他操作


非常感谢您的帮助。

您需要保留特定的重定向,然后才能使用通用的全包重定向:

redirect 301 /mobile-cars/for-her/kia-moto /kia-12.html
redirect 301 /mobile-cars/for-her /cars-for-her/
redirect 301 /mobile-cars/for-him /cars-for-him/
redirect 301 /mobile-cars /cars/
或使用重定向匹配:

RedirectMatch 301 ^/mobile-cars/for-her/kia-moto /kia-12.html
RedirectMatch 301 ^/mobile-cars/(for-her|for-him) /cars-$1/
RedirectMatch 301 ^/mobile-cars /cars/

令人惊叹的!非常感谢。使用AWS S3301重定向XML配置可以解决同样的问题吗?这是特定于Apache的。我没有重定向的XML配置方面的工作知识。