I
I
invisii2020-07-19 15:51:06
htaccess
invisii, 2020-07-19 15:51:06

Hataccess redirect with ampersand (&)?

Good afternoon. Tell me how to redirect everything after the ampersand (sign &) in the URL to what is before it, while the ampersand should remain. Example:

/review/report.php?id=1131&item_id=21&PHPSESSID=69c6a854f33cc07d61b81257b45d4cf5 
на
/review/report.php?id=1131&item_id=21&

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2020-07-19
@invisii

?id=1&item_id=2&PHPSESSID=abc
?id=1&PHPSESSID=abc&item_id=2
?PHPSESSID=abc&id=1&item_id=2

If you need to remove the PHPSESSID and leave the rest of the GET parameters.
RewriteCond %{QUERY_STRING} ^(|.*&)PHPSESSID=[^&]*&?(.*)
RewriteRule ^review/report\.php$ /$0?%1%2 [R=301,L]

V
Viktor Taran, 2020-07-19
@shambler81

The Get parameter is not part of the URL and RewriteRule does not physically see it.

RewriteCond %{QUERY_STRING} (^|&)id\=1131($|&)
RewriteCond %{QUERY_STRING} (^|&)item_id\=21($|&)
RewriteCond %{QUERY_STRING} (^|&)PHPSESSID\=69c6a854f33cc07d61b81257b45d4cf5($|&)
RewriteRule ^review/report\.php$ /review/report.php?id=1131&item_id=21& [L,R=301]

I recommend
https://donatstudios.com/RewriteRule_Generator
also sometimes you need to escape special characters in the drain where, but it depends on the specific web server, somewhere it is required somewhere not
eport.php?id
eport.php\?id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question