非WWW的.htaccess重定向 - 忽略其他子域 [英] non www .htaccess redirect - ignore other subdomains
问题描述
我有一个htaccess的重定向非www的是这样的:
I have a .htaccess redirect for "non www" like this:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
这是工作。但是,我也有一些子域名比WWW等。 如果我呼吁例如 http://shop.example.com 它重定向我: http://www.shop.example.com
it is working. But, i have also some subdomains other than www. If I call for example http://shop.example.com it redirects me to: http://www.shop.example.com
我不想写的子域到.htaccess文件,它会自动工作,只是忽略了别的比www和''是这样的:
I dont want to write the subdomains into the .htaccess file, it should work automatically, just ignore anything else than www and '' like this:
if subdomain =='' -> redirect to www.HTTP_HOST....
elseif subdomain !='' && subdomain !='www' -> do nothing.
谢谢!
推荐答案
试试这个:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST}//s%{HTTPS} ^www\.(.*)//((s)on|s.*)$ [NC]
RewriteRule ^ http%3://%1%{REQUEST_URI} [L,R=301]
只是试图与 internetagentur.drupal-webmaster.de (子域) - 主要是不WWW。
Just tried it with internetagentur.drupal-webmaster.de (the subdomain) - the main is without www.
这篇关于非WWW的.htaccess重定向 - 忽略其他子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!