0

Need make a redirect to 410 server response from this page - http://example.com/product_info.php?products_id=1 Tried many options, but they did not work, for example this:

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

For url's like this - http://example.com/?cat=79 work variant:

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

And accordingly this one too not work

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

.htaccess file:

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> 
hopea114y
  • 11
  • 5
  • First of all, I think you should add the `L` flag. Secondly, show us your full .htaccess including all the relevant rules. – CBroe May 14 '18 at 11:16
  • (`RewriteCond %{QUERY_STRING} /?cat=79` only “works” because the question mark makes the slash optional; the actual query string in that case is of course _not_ `/?cat=79`) – CBroe May 14 '18 at 11:18
  • Adding L - flag in all options not help - RewriteRule .* - [G,L] – hopea114y May 14 '18 at 12:08

1 Answers1

0

Working variant:

RewriteCond %{QUERY_STRING} (^|&)products_id\=1($|&)
RewriteRule .* - [G,NC]
hopea114y
  • 11
  • 5
  • This is not an answer to the question, so please don’t post it as that. _Edit your question_ instead to add more info to it. – CBroe May 14 '18 at 12:15