【问题标题】:Subdomain Mod-Rewrite issue Internal redirection doesn't work子域 Mod-Rewrite 问题内部重定向不起作用
【发布时间】:2014-02-07 16:50:13
【问题描述】:

我正在尝试使用 htaccess 让子域为我的站点工作,例如:

shopping.site.local 应该将用户引导到 site.local/shopping-and-fashion 并保持初始子域格式,这意味着在用户无法注意到的内部重定向中。

我添加了以下脚本:

RewriteCond %{HTTP_HOST} ^shopping.site.local$ [OR]
RewriteCond %{HTTP_HOST} ^www.shopping.site.local$
RewriteRule ^(.*)$ http://www.site.local/shopping-and-fashion/$1 [L]

重定向成功但以外部方式发生,如何隐藏重定向以始终拥有 url:

http://shopping.site.local

和内容:

http://www.site.local/shopping-and-fashion

【问题讨论】:

    标签: mod-rewrite redirect internal silent


    【解决方案1】:

    你试过用 [P] 代替 [L] 吗?

    【讨论】:

      【解决方案2】:

      以下使用反向代理,应该给你你想要的

      <VirtualHost *:80>
        ServerName shopping.site.local
        ProxyPass / http://www.site.local/shopping-and-fashion/ nocanon
        ProxyPassReverse / http://www.site.local/shopping-and-fashion/
      </VirtualHost>
      

      如果原始文件不是相对链接友好的,您可能需要修改一些 JS 和 CSS 以适应路径更改。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-18
        • 1970-01-01
        • 2023-04-05
        • 2011-05-06
        • 1970-01-01
        • 2012-12-29
        相关资源
        最近更新 更多