【问题标题】:Redirecting with .htaccess to external domain使用 .htaccess 重定向到外部域
【发布时间】:2014-12-12 12:20:36
【问题描述】:

我试图弄清楚如何使用 .htaccess 重定向到外部域。基本上这是我想做的重定向。

重定向:http://www.domain.eu/nlhttp://www.domain.nl/nl。但我也想用某些子目录重定向更深层次的链接。

重定向:http://www.domain.eu/nl/news/100-article-with-a-name/http://www.domain.nl/nl/news/100-article-with-a-name/

谁能帮我弄清楚如何做到这一点?或者有人有帮助我的关键提示吗? 两个域都在运行 Joomla 3.x 安装。

【问题讨论】:

    标签: regex .htaccess redirect


    【解决方案1】:

    您可以使用以下 .htaccess 代码将主域和所有页面重定向到其他域:

     RewriteEngine on 
     RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
    

    如果您有任何疑问,请询问。

    【讨论】:

    • 您好,感谢您的意见。我正在尝试将具有 domain.eu/nl/some-category/some-article 的每个 url 重写为 domain.nl/nl/some-category/some-article。以上我也想通了。不幸的是,我还没有找到如何从更深的文章/目录重定向。你能给我一个小费吗? :)
    • 你试过我给定的代码了吗?它适用于基础和所有子页面 URL。
    • 这两行不解决,只是重定向到其他域,不包含子页面路径。
    • 我想你会在这里得到解决方案:gist.github.com/ScottPhillips/1721489
    • RewriteCond %{REQUEST_URI} ^/nl/(.*)$ RewriteRule ^(.*) http://www.domain.nl/nl/%1 [R=303,NC] 每当我尝试将http://www.domain.eu/nl/contact重定向到http://www.domain.nl/nl/contact时,这仍然会重定向错误
    猜你喜欢
    • 2012-12-08
    • 2016-09-23
    • 2012-06-03
    • 1970-01-01
    • 2014-08-19
    • 2013-02-20
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多