【问题标题】:Urls redirect in .htaccess.htaccess 中的 URL 重定向
【发布时间】:2018-03-18 05:22:36
【问题描述】:

我的网址有http://test.com//123.html

注意它有 // 来自不受我控制的第 3 方,所以我想捕获 // url 并将其重定向到单斜杠。我的 .htaccess 中有这个

RewriteCond %{REQUEST_URI} ^(.*)//(.*)$<br>
RewriteRule . %1/%2 [R=301,L]

但是它不起作用,我仍然在浏览器中看到 //。我的代码有问题吗?

【问题讨论】:

    标签: apache .htaccess redirect


    【解决方案1】:

    试试这个

    RewriteCond %{REQUEST_METHOD}  !=POST
    RewriteCond %{REQUEST_URI} ^(.*?)(/{2,})(.*)$
    RewriteRule . %1/%3 [R=301,L]
    

    查看this

    【讨论】:

      猜你喜欢
      • 2011-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-05
      相关资源
      最近更新 更多