N
N
Nikita0802019-03-06 23:45:55
Search Engine Optimization
Nikita080, 2019-03-06 23:45:55

301 redirect not working, what's wrong?

Good evening everyone. I tried to make a redirect from one url address - to the CNC address. Inside the site, the URLs were rewritten in cnc. That is, you need a 301 redirect from one page to another. Since when creating the CNC, the old URLs also remained, and these are duplicate pages that need to be glued together. Editing in htaccess file. But after editing it doesn't work. Where is the mistake?
Need a redirect from a page like https://mirtreiderov.ru/blog/index?BlogPostSearch%...
to a page like https://mirtreiderov.ru/blog/theme/finanasovie-novosti5c80310a6b602373330714.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-03-07
@dodo512

The Redirect directive belongs to mod_alias and there is no way to match the template with GET parameters.
But mod_rewrite has such an opportunity.

RewriteCond %{QUERY_STRING} ^BlogPostSearch(?i:%5B|\[)theme_id(?i:%5D|\])=1$
RewriteRule ^blog/index$ https://mirtreiderov.ru/blog/theme/finanasovie-novosti? [R=301,L]

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^blog/index$ https://mirtreiderov.ru/blog [R=301,L]

Set immediately after RewriteEngine On.
And remove the lineRedirect 301 /blog/index /blog

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question