【问题标题】:Apache Redirect to static locationApache重定向到静态位置
【发布时间】:2014-11-25 16:29:52
【问题描述】:

我需要将任何 url 从一个域重定向到另一个域上的一个静态 url 示例:

http://myexample.com -> redirect to http://example.myexample.com
http://myexample.com/example -> redirect to http://example.myexample.com

我见过很多重定向将 /example 带到重定向站点的示例。

我不想要这个...我需要任何 url,无论重定向到的参数如何:

http://example.myexample.com

【问题讨论】:

    标签: apache redirect


    【解决方案1】:

    这应该很简单,见下文:

    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} ^myexample.com$
    RewriteRule ^ http://example.myexample.com/? [R,L]
    

    这将重定向任何东西点击myexample.com,无论http://example.myexample.com/的路径如何

    【讨论】:

    • 它似乎不起作用。 myexample.com/example 重定向到 subdomain.myexample.comexample/...it 似乎将 /example 带到重定向的末尾...然后我找不到一个页面...这些不在同一个域或子域上,我只是使用 example 和 myexample 作为占位符
    • 文件中还有其他规则吗?仅凭上述规则是不可能做到这一点的。
    • 这一切都在我启用站点的配置中... RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com$ RewriteRule ^ dashboard.example.com [R,L] IfModule>
    • 您的站点中是否有任何 .htaccess 文件?必须是别的地方。请注意,我现在对答案进行了小修改,以删除任何查询字符串。
    • 我正在测试,但在我的 apache2.conf 中我已经注释掉了 #AccessFileName .htaccess...我仍然得到 example.myexample.comexample/...I 认为这会阻止所有 .htaccess 被加载
    猜你喜欢
    • 2011-02-12
    • 2011-08-03
    • 1970-01-01
    • 1970-01-01
    • 2020-10-19
    • 1970-01-01
    • 2014-07-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多