L
L
Lici2013-07-25 19:53:21
CMS
Lici, 2013-07-25 19:53:21

Redirect 301 and question mark in URL

You need to redirect a number of pages to new addresses. The problem is that the pages contain a question mark and therefore the redirect via the htazzes of the form does not work:

Redirect 301 /?module=View&category=ololo site.ru/new

And the character / question mark is not escaped. Can you tell me how to make a redirect in this case? Only a monster crutch in php came to mind, which will issue on all pages of the site:

IF you are on a page like this, THEN header("HTTP/1.1 301 Moved Permanently");

Is there any correct and "clean" solution to the issue with the question mark in the URL and the redirect?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
N
Nikolai Vasilchuk, 2013-07-25
@Anonym

For example like this

RewriteCond %{QUERY_STRING} ^foo=bar&bar=baz$
RewriteRule ^(.*)$ http://www.example.com [R=301,L]

K
kenny_opennix, 2013-07-26
@kenny_opennix

if ($query_string ~ "^?module=View&category=ololo")
 { 
  rewrite ^(.*)$ http://site.ru/new redirect; 
  }

works great.

N
Nazar Mokrinsky, 2013-07-25
@nazarpc

So the backslash is used for escaping \

S
slon362, 2015-07-12
@slon362

nginx: [emerg] pcre_compile() failed: nothing to repeat in "^?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question