在网址重写PHP像子域 [英] Url Rewriting like Subdomain in PHP
本文介绍了在网址重写PHP像子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要重写URL像子域的风格。
例如,如果主URL是mysite.com/test比我想重写它像test.mysite.com
mysite.com/test => test.mysite.com
能否请你建议我应该我需要在.htaccess文件中添加什么重写规则。
先谢谢了。
解决方案
的RewriteCond%{HTTP_HOST} ^ $ mysite.com [NC]
重写规则^(+)$ HTTP://$1.mysite.com [L,R = 301]
应该这样做,可能需要一点点调整
I want to rewrite url as like subdomain style.
For example if main url is mysite.com/test than i want to rewrite it like test.mysite.com
mysite.com/test => test.mysite.com
Can you please suggest me what rewrite rule should i need to add in .htaccess file.
Thanks in advance.
解决方案
RewriteCond %{HTTP_HOST} ^mysite.com$ [NC]
RewriteRule ^(.+)$ http://$1.mysite.com [L,R=301]
Should do it, might need a little tweaking
这篇关于在网址重写PHP像子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文