我有很多网站,可以在子域上访问,如:
website1.com.banana.servers.com
website2.net.apple.servers.com
website3.com.avocado.servers.com我也有他们中的每一个相应的域名:
website1.com
website2.net
website3.com我需要做的就是编写一个通用的.htaccess规则,将子域(以randomWord.servers.com结尾)重定向到一个短域。
例如:website1.com.banana.servers.com应该成为-> website1.com
发布于 2017-02-03 17:35:55
像这样试一试我现在还没试过,
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^\/]*)\.([^\/]*)\.([^\/]*)\.([^\/]*)\.com
RewriteRule ^ http://%1.com [R=301,L]发布于 2017-02-03 17:33:46
#The line above tells the server to turn on the engine for rewriting urls.
RewriteEngine On
#If the host is "sub.domain.com"
RewriteCond %{HTTP_HOST} ^sub.domain.com$ [NC]
#Then rewrite any request to /folder
#This line is a condition for the RewriteRule where We match against the http Host using regex pattern. The condition says that if the host is sub.domain.com then execute the Rule.
RewriteRule ^((?!folder).*)$ /folder/$1 [NC,L]https://stackoverflow.com/questions/42020789
复制相似问题