【问题标题】:apache mod rewrite condition - ruleapache mod 重写条件 - 规则
【发布时间】:2016-10-26 10:18:45
【问题描述】:

我要抓取网址,检查网址是否包含“#!”并重定向到没有“#!”的相同网址细绳?我尝试了以下方法 - 但这不起作用?

RewriteCond %{REQUEST_URI} "(.*).html#!$"
RewriteRule "(.*)" $1 [NC,L,R=301]

【问题讨论】:

    标签: apache url-rewriting


    【解决方案1】:

    试试那个:

    RewriteCond %{REQUEST_URI} ".*\.html#!$"
    RewriteRule "^(.*\.html)#!$" $1 [NC,L,R=301]
    

    【讨论】:

      【解决方案2】:

      很遗憾,之前的解决方案是错误的。服务器不会处理网格符号后的数据:

      [27/Oct/2016:10:23:12 +0300] domain.com xx.xx.xx.xx xx.xx.xx.xx 200 0 0.000 HEAD /index.html HTTP/1.1 - curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
      
      $ curl -I 'http://domain.com/index.html#!1asfasgf1ghgh'
      HTTP/1.1 200 OK
      Server: nginx/1.10.1
      Date: Thu, 27 Oct 2016 07:23:14 GMT
      Content-Type: text/html; charset=UTF-8
      Content-Length: 9977
      Connection: keep-alive
      Last-Modified: Sat, 23 Jan 2016 14:06:07 GMT
      ETag: "a66b6-26f9-52a00d64891c0"
      Accept-Ranges: bytes
      Vary: Accept-Encoding
      

      【讨论】:

        猜你喜欢
        • 2012-06-14
        • 1970-01-01
        • 2017-08-31
        • 2015-07-26
        • 2010-11-13
        • 2012-05-13
        • 1970-01-01
        • 2015-09-22
        • 1970-01-01
        相关资源
        最近更新 更多