【问题标题】:Url Rewriting like Subdomain in PHP像 PHP 中的子域一样重写 URL
【发布时间】:2012-08-13 20:25:45
【问题描述】:

我想像子域样式一样重写 url。

例如,如果主 url 是 mysite.com/test,我想像 test.mysite.com 一样重写它

mysite.com/test => test.mysite.com

您能否建议我应该在 .htaccess 文件中添加什么重写规则。

提前致谢。

【问题讨论】:

标签: php apache .htaccess url-rewriting


【解决方案1】:
RewriteCond %{HTTP_HOST} ^mysite.com$ [NC]
RewriteRule ^(.+)$ http://$1.mysite.com [L,R=301]

应该这样做,可能需要一些调整

【讨论】:

  • 感谢您的回复@william。让我检查一下。
猜你喜欢
  • 2016-09-24
  • 1970-01-01
  • 2011-09-19
  • 1970-01-01
  • 1970-01-01
  • 2014-11-14
  • 2012-09-17
  • 1970-01-01
相关资源
最近更新 更多