2014-02-26 38 views
0

我想重定向取决于用户输入的URL,如果用户输入ins-dev.com被重定向到确切的一个,如果输入www.ins-dev.com删除www和重定向到ins-dev.com(http://)。 但是,如果用户输入ins-staging.com在https://ins-staging.com上重定向,在www的情况下将其删除并执行相同的重定向。 最后,如果用户输入trac-staging.com,我希望将他重定向到https://ins-staging.com,这与www的逻辑相同。 这是我现在:URL取决于重定向htaccess

RewriteEngine On 
RewriteCond %{HTTPS} off [OR] 
RewriteCond %{HTTP_HOST} ^www\. [OR,NC] 

RewriteCond %{REQUEST_URI} ^ins-dev.com$ 
RewriteRule ^$ http://ins-dev.com [L,R=301] 


RewriteCond %{HTTP_HOST} ^trac-staging\.com$ [NC] 
RewriteRule^https://ins-staging.com%{REQUEST_URI} [L,R=301] 

与此很长一段时间,现在提前对任何形式的帮助战斗,谢谢。 最后%{REQUEST_URI}为目的,如果用户例如输入:ins-staging.com/video.php

回答

0

您可以使用:

RewriteEngine On 

RewriteCond %{HTTPS} off [OR] 
RewriteCond %{HTTP_HOST} ^www\.((?:trac-staging|ins-staging)\.com)$ [NC] 
RewriteRule^https://%1%{REQUEST_URI} [L,R=301,NE] 

RewriteCond %{HTTPS} off 
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC] 
RewriteRule^http://%1%{REQUEST_URI} [L,R=301,NE] 

RewriteCond %{HTTPS} on 
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC] 
RewriteRule^https://%1%{REQUEST_URI} [L,R=301,NE] 
+0

感谢重播,我想这和我重定向到本地主机中除了一个“https:// ins-staging.com”的案例外 – Wolf87