V
V
Vitaly Mironov2019-10-10 20:59:18
htaccess
Vitaly Mironov, 2019-10-10 20:59:18

How to make an ajax request redirect?

There is a link in an ajax request of the form - https://example.com/ru/?wc-ajax=get_refreshed_fragments
It is necessary that a redirect to https://example.com/en/?wc-ajax=get_refreshed_fragments
I tried to write like this, but did not help:

RewriteCond %{HTTP_HOST} ^example.com$
RewriteCond %{QUERY_STRING} wc-ajax
RewriteRule ^$ https://example.com/en/? [R=301,L]

and
RewriteCond %{HTTP_HOST} ^example.com$
RewriteCond %{QUERY} ^wc-ajax [NC]
RewriteRule ^$ https://example.com/en/? [R=301,L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wisgest, 2019-10-11
@nor1m

^$( Only an empty string matches the regex .)
Try this (didn't test it, and I'm new to mod_rewrite myself):

RewriteCond %{QUERY_STRING} wc-ajax
RewriteRule ^ru/(.*) /en/$1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question