S
S
Sergey Bard2017-08-05 12:30:43
htaccess
Sergey Bard, 2017-08-05 12:30:43

Why are htaccess rules not working?

I ask for help. I write rules in .htaccess, and for example, such a 301 redirect works

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

for such a page https://site.com/?post_type=shop_order&p=86/commen...
and here are the rules
RewriteCond %{QUERY_STRING} ^type=rss$
RewriteRule (.*) $1? [R=301,L]
Для этого https://site.com/blog/retsepty-s-medom.feed?type=rss

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

и для этого https://site.com/add.html?category_id=1&product_id=2

they don’t want to work no matter how I write.
I ask for help, because I went through a lot of resources, I tried a bunch of options that don’t work

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Bard, 2017-08-07
@serg_small_developer

For those who are interested, I solved the problem in this way

Options +SymLinksIfOwnerMatch
RewriteEngine on
Redirect 301 /blog/retsepty-s-medom.feed https://site.com/

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

For such a link https://site.com/blog/retsepty-s-medom.feed?type=rss I did the same with the rest, i.e. first there is a redirect to the main page, but in fact we get to https://site.com/?type=rss, and then I redirect all such requests to the main page

W
WordPress WooCommerce, 2017-08-05
@maxxannik

Do you have Apache or pure nginx? If the second, then htaccess will be ignored and the whole rule must be written in the config.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question