的.htaccess重写子域目录 [英] .htaccess rewrite subdomain to directory
本文介绍了的.htaccess重写子域目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能使用的.htaccess重写一个子域到目录?
Is it possible to use .htaccess to rewrite a sub domain to a directory?
例: HTTP:// 分 .domain.com /显示 http://domain.com/subdomains/的内容一> 分 /
Example: http://sub.domain.com/ shows the content of http://domain.com/subdomains/sub/
推荐答案
尝试把这个在你的.htaccess文件:
Try putting this in your .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^sub.domain.com
RewriteRule ^(.*)$ http://domain.com/subdomains/sub/$1 [L,NC,QSA]
有关更一般的规则(即与任何子域的作品,而不仅仅是子
)这个替换最后两行:
For a more general rule (that works with any subdomain, not just sub
) replace the last two lines with this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com
RewriteRule ^(.*)$ http://domain.com/subdomains/%1/$1 [L,NC,QSA]
这篇关于的.htaccess重写子域目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文