简体   繁体   English

.htaccess 301使用相同路径重定向

[英].htaccess 301 redirect with same path

Redirect 301 /exampleDomain/ http://www.example.com/exampleDomainChanged/

Redirect 301 /exampleDomain/more/ http://example.com/changedMore/more1

exampleDomain is firstly changed into exampleDomainChanged but the problem is with the second URL, /exampleDomain/more/ "exampleDomain" is already changed to exampleDomainChanged 首先将exampleDomain更改为exampleDomainChanged,但是问题出在第二个URL上,/ exampleDomain / more /“ exampleDomain”已更改为exampleDomainChanged

but I need it to be "changedMore" in this case. 但在这种情况下,我需要将其更改为“ changedMore”。

What rewrite rules I have to apply here in .htaccess? 我必须在.htaccess中应用哪些重写规则?

I tried RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] 我尝试了RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

but it gives too many redirects on index page. 但它在索引页面上提供了太多的重定向。

You need list the most specific rules at the top. 您需要在顶部列出最具体的规则。

If you swap out the rules, this should work as expected. 如果您换掉规则,这应该可以正常工作。

Redirect 301 /exampleDomain/more/ http://example.com/changedMore/more1

Redirect 301 /exampleDomain/ http://www.example.com/exampleDomainChanged/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM