Good time of day! Made the conversion of dynamic addresses to static. Please tell me, now how to make Redirect from old dynamic URL to new static URL . You need to redirect with

Site.ru/?q=рег . Expression

on

site.ru/search/рег . Expression

  • Only in the link do not use Cyrillic - Saidolim
  • This is how a redirect does not work at all ... (I’m suffering already for 3 days, I can’t find a solution. - Ididonon
  • I checked the site htaccess.mwl.be and tests all pass normally. Is there exactly Cyrillic? - Saidolim
  • after adding RewriteRule ^ search / (. *)? (. *) $ search / $ 1? [L, NC] I get an error 500 - Identin

1 answer 1

Try this, corrected, now it works too

 RewriteCond %{QUERY_STRING} ^q=(.*)$ RewriteRule ^(.*)$ search/%1? [L] 

UPD:

here is the working code

 RewriteCond %{QUERY_STRING} q=(.*) RewriteRule ^$ search/%1 [L,R=301,NC] RewriteRule ^search/(.*)?(.*)$ search/$1? [L,NC] 

Is the most important thing a sign ? in the end. It deletes the previous query with ?q=...

  • Does not work. I converted site.ru/?q= to site.ru/search/ and now when I redirect so: RewriteCon d% {QUERY_ STRING} ^ q = ([0-9] *) $ RewriteRul e ^ (. *) $ search /% 1 [L] on the search / blabla page I get the content? q = blabla, that is, I get again the redirector which I did above. And the error 301. - Identin
  • @ Identicon check update - Saidolim
  • @ Identicon try the first option, there I changed it. should work too. if 2nd didn't work for you - Saidolim
  • I tried both options, nivkakuyu. The tester swears at the flags L, I replaced them with P, the redirect is obtained but the error page 302 (301) opens. If you do not redirect, harm the site it? After all, it turns out duplicate pages. onmuz.ru/?q=olga and onmuz.ru/search/olga are the same content. - Ididon