There is a link of the form

domain.ru/news/1234/?ads=1 

need to redirect to:

 domain.ru/ads 

If you use a rule

 RewriteRule ^news/([0-9]+)/?ads=([0-9]+)$ /ads [R=301,L] 

that doesn't work, but if you replace the mark ? on any other character, everything is ok. Help solve the problem. Tried to screen

 RewriteRule ^news/([0-9]+)/\?ads=([0-9]+)$ /ads [R=301,L] 

replace

 RewriteRule ^news/([0-9]+)/(.)ads=([0-9]+)$ /ads [R=301,L] 

nothing works.

  • decipher "does not work" - crash the browser, does not go anywhere, goes, but to the left address. Also try using curl to contact curl at this address curl -I -L domain.ru/news/1234/?ads=1 and look at the output. - KoVadim

1 answer 1

Try this:

 RewriteCond %{QUERY_STRING} ^ads=([0-9]*)$ RewriteRule ^news/([0-9]+)/$ /ads [R=301,L] 
  • Thank! It works this way, but the link now looks like domain.ru/ads/?ads=1 - KingStakh
  • @KingStakh and if so: RewriteRule ^news/([0-9]+)/(.*)$ /ads [R=301,L] ? - Alex Chermenin