410使用动态GET参数重定向url

时间:2018-05-14 11:12:24

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

需要从此页面重定向到 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
RewriteCond %{HTTP_HOST} ^www.karavanmatrasov\.by$ [NC]
RewriteRule ^(.*)$ http://karavanmatrasov.by/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.php$
RewriteRule ^(.*)index.php$ http://karavanmatrasov.by/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://karavanmatrasov.by/$1 [R=301,L]

#
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> 

1 个答案:

答案 0 :(得分:0)

工作变体:

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