【问题标题】:410 redirect url with dynamic GET parameters带有动态 GET 参数的 410 重定向 url
【发布时间】:2018-05-14 11:12:24
【问题描述】:

需要从这个页面重定向到 410 服务器响应 - http://example.com/product_info.php?products_id=1 尝试了很多选项,但它们都不起作用,例如:

RewriteCond %{QUERY_STRING} ^products_id=1$
RewriteRule ^.*$ - [G,NC]

对于这样的网址 - http://example.com/?cat=79 工作变体:

RewriteCond %{QUERY_STRING} /?cat=79
RewriteRule .* - [G,NC]

因此这个也行不通

RewriteCond %{QUERY_STRING} /?products_id=1
RewriteRule ^.*$ - [G,NC]

.htaccess 文件:

AddDefaultCharset utf-8
ErrorDocument 404 /404.html
ErrorDocument 410 default
RewriteEngine On
RewriteBase /

#SEO
RewriteRule ^index\.php$ /? [L,R=301]

#10.01.2018 Redirect index.php to /
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
php_value magic_quotes_gpc                0
php_value register_globals                0
php_value session.auto_start              0
php_value mbstring.http_input             pass
php_value mbstring.http_output            pass
php_value mbstring.encoding_translation   0
php_value default_charset UTF-8
php_value mbstring.internal_encoding UTF-8
</IfModule> 

【问题讨论】:

  • 首先,我认为您应该添加L 标志。其次,向我们展示您的完整 .htaccess,包括所有相关规则。
  • (RewriteCond %{QUERY_STRING} /?cat=79 仅“有效”,因为问号使斜杠成为可选;在这种情况下,实际的查询字符串当然是 not /?cat=79)
  • 在所有选项中添加 L - 标志无济于事 - RewriteRule .* - [G,L]

标签: .htaccess http-status-code-410


【解决方案1】:

工作变体:

RewriteCond %{QUERY_STRING} (^|&)products_id\=1($|&)
RewriteRule .* - [G,NC]

【讨论】:

  • 这不是问题的答案,所以请不要这样发布。 编辑您的问题 以添加更多信息。
猜你喜欢
  • 1970-01-01
  • 2021-12-28
  • 2014-02-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-07-01
  • 1970-01-01
  • 2015-04-02
相关资源
最近更新 更多