【问题标题】:Rewrite from sub domain without change url从子域重写而不更改 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的变化,但我不需要它。

【问题讨论】:

    标签: php apache .htaccess mod-rewrite


    【解决方案1】:

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

    ln -s  /path-to/subdomain codefolder
    

    在htaccess中

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-01
      • 2014-05-10
      • 2014-01-18
      • 1970-01-01
      • 2017-02-02
      • 2015-02-18
      • 2013-02-25
      • 1970-01-01
      相关资源
      最近更新 更多