L
L
loed2020-06-30 13:04:13
htaccess
loed, 2020-06-30 13:04:13

Redirect url with variables, how to do it?

The travelline script for number search generates a url of this type "/booking.html?date=2020-07-05&nights=3&adults=1" (variables depending on dates, and number of people) . How to make a redirect to the /booking/ page while saving the variable?
Site no wordpress.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2020-06-30
@Stalker_RED

RewriteRule ^booking\.html(.*)$ booking/$1 [R=301,L]

https://htaccess.madewithlove.be?share=702e3cea-77...

V
Viktor Taran, 2020-06-30
@shambler81

RewriteCond %{QUERY_STRING} (^|&)date\=.+($|&)
RewriteCond %{QUERY_STRING} (^|&)nights\=.+($|&)
RewriteCond %{QUERY_STRING} (^|&)adults\=.+($|&)
RewriteRule ^booking\.html$ /booking/ [L,R=301]

Please note that GET is not part of the RewriteRule url, it cannot select it, RewriteCond %{QUERY_STRING} is used for this, and group variables are inserted from it as %1 %2 and so on

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question