【问题标题】:htaccess Redirect 301 friendly link with non friendly tailhtaccess 重定向 301 带有非友好尾部的友好链接
【发布时间】:2020-02-09 20:53:19
【问题描述】:

我在 .htaccess 文件中遇到 301 重定向问题。 是的,它应该在 htaccess 中完成。

我有带有非友好尾部的友好链接,带有 utf-8 字符:

https://example.com/plotno-16x24?tag=Fotobraz na płótnie

我正在尝试将其重定向到 https://example.com/404 带代码:

RewriteRule ^plotno-16-24?tag=([^?]*)$ /404 [R=301,NE,NC,L]

但它只在问号之前有效,在这个符号“?”之后。它总是失败。

有什么想法吗?

【问题讨论】:

    标签: .htaccess mod-rewrite http-status-code-301


    【解决方案1】:

    ? 或 QUERY_STRING 的一部分在 RewriteRule 中不匹配。你可以使用这条规则:

    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} /plotno-16-24\?tag=. [NC]
    RewriteRule ^ /404? [R=30,L,NE]
    

    还要注意在/404 之后使用? 会去除任何预先存在的查询字符串。

    【讨论】:

      猜你喜欢
      • 2017-08-03
      • 1970-01-01
      • 2014-02-24
      • 1970-01-01
      • 1970-01-01
      • 2012-12-07
      • 1970-01-01
      • 2013-01-06
      • 1970-01-01
      相关资源
      最近更新 更多