从子域重写而不更改 url

Posted

技术标签:

【中文标题】从子域重写而不更改 url【英文标题】:Rewrite from sub domain without change url 【发布时间】:2017-09-17 10:49:10 【问题描述】: 结构 public_html -.htaccess -子域 -代码文件夹

子域 应在codefolder 中查找但未更改URL 的任务。有可能吗?

我试试

重写引擎开启 RewriteCond %HTTP_HOST subdomain.example.com RewriteCond %REQUEST_URI !^subdomain.example.com 重写规则 ^(.*)$ http://example.com/ [L]

但它肯定会导致URL的变化,但我不需要它。

【问题讨论】:

【参考方案1】:

我通过符号链接解决了这个问题。

ln -s  /path-to/subdomain codefolder

在htaccess中

RewriteEngine On

RewriteCond %HTTP_HOST ^([^\.]+)\.example\.com
RewriteRule ^(.*) /example/public/%1 [L]

这不是最佳选择,但我的主机无法访问 Apache 配置。

【讨论】:

以上是关于从子域重写而不更改 url的主要内容,如果未能解决你的问题,请参考以下文章