Y
Y
Yuri Repin2016-08-04 17:44:46
Regular Expressions
Yuri Repin, 2016-08-04 17:44:46

How to write regular expressions in .htaccess correctly?

Good day everyone, I need help with .htaccess For
two days I can’t understand how it works, I just haven’t tried it.
Let's get to the point, there is a link:
domain.ru/s_shoping/shop?sid=253%23modal/bundle/82522
It contains the symbol %23, I need to replace it with (#) hash.
Such links appear, for example, if you share a link in Skype on ios, maybe other programs have the same problem.
As I just did not try to write:

RewriteRule ^(/shop\?sid=[0-9]*)?%23(modal/bundle/[0-9]*)$ /shop\?sid=$1#modal/bundle/$2 [NE,R=301,L]
RewriteRule ^(.*)?%23(.*)?$ $1#$2 [NE,R=301,L]

In general, I tried a dozen options, with different flags, additional modules, etc. but it's useless...
What am I doing wrong? If you use one group, then everything works, if two already break (or if you add any character behind the group, it also doesn’t work)
There is nothing special about these regular expressions ... Or maybe you can get by with changing the encoding ...
Thank you in advance for any hint

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Repin, 2016-08-10
@Spalz

I had to go through the documentation again and it turned out like this:

RewriteBase /s_shoping/
RewriteCond %{QUERY_STRING} ^(.*?)(%23)(.*?)$
RewriteRule ^(shop.php?)$ shop?%1#%3 [NC,L,R=301,NE]

V
Viktor Taran, 2016-08-05
@shambler81

you have a redirect with a get request, it is not part of the url.
they do it differently.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question