【问题标题】:Apache URL rewrite trick to fix encoded "http://"Apache URL 重写技巧来修复编码的“http://”
【发布时间】:2013-02-22 18:35:00
【问题描述】:

我有一些导致最终格式不佳的网站,例如:

http://www.mydomain.com/directory/http%3A%2F%2Fwww.another.com%2Falink-that-doesnt-work

我想要一个重写规则来截断该部分直到 url 并修复编码以重定向到

http://www.another.com/alink-that-doesnt-work

谢谢

【问题讨论】:

    标签: mod-rewrite seo


    【解决方案1】:

    使用正则表达式从 URL 中提取主机名和链接,并使用反向引用来替换和重定向。请注意,模式与解码的 URL 匹配。

    RewriteEngine On
    RewriteRule   /directory/http://([^/]*)/(.*)    http://$1/$2   [R]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-18
      • 2010-11-17
      • 2011-03-04
      • 1970-01-01
      相关资源
      最近更新 更多