htaccess-重定向除一个网址外的所有网址 [英] Htaccess - Redirect all but one url
问题描述
我正在尝试将所有url从一个域重定向到另一个域,而不是一个(那种).这是我必须重定向的htaccess,除了域外,所有其他URL都保持相同(例如domain.com/something转到domain2.com/something).
RewriteEngine开启RewriteBase/RewriteCond%{HTTP_HOST} ^ domain.com $ [OR]RewriteCond%{HTTP_HOST} ^ www.domain.com $RewriteRule ^(.*)$"http://domain2.com/$1" [R = 301,L]
我想知道的是如何全部重定向,除非URL为domain.com/validation/*
/validation/不是子文件夹,它必须是域后url的下一部分(domain.com/something/validation可以重定向,而domain.com/validation/something不能).>
我尝试了很多选择,但是没有一个:(
我希望有足够的信息.
您可以在 RewriteRule
本身中排除它:
RewriteEngine开启RewriteCond%{HTTP_HOST} ^(www \.)?domain \ .com $ [NC]RewriteRule!^ validation http://domain2.com% {REQUEST_URI} [NE,NC,R = 301,L]
I'm trying to redirect all urls from one domain to another but one (kind of). This is the htaccess I have to redirect all keeping the same url except of the domain (for example domain.com/something goes to domain2.com/something).
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^(.*)$ "http://domain2.com/$1" [R=301,L]
What I want to know is how to redirect all except if the url is domain.com/validation/*
/validation/ is not a subfolder and it has to be the next part of the url after the domain (domain.com/something/validation can redirect, and domain.com/validation/something can't).
I tried a lot of options but none worked :(
I hope is enough information.
You can exclude it in RewriteRule
itself:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule !^validation http://domain2.com%{REQUEST_URI} [NE,NC,R=301,L]
这篇关于htaccess-重定向除一个网址外的所有网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!