how do I redirect multiple url to another one url
I have tried but its not working
RewriteCond %{HTTP_HOST} ^sub.domain.to/q1$ [NC,OR]
RewriteCond %{HTTP_HOST} ^sub.domain.to/q2$ [NC,OR]
RewriteCond %{HTTP_HOST} ^sub.domain.to/q3$ [NC,OR]
RewriteCond %{HTTP_HOST} ^sub.domain.to/q4$ [NC,OR]
RewriteCond %{HTTP_HOST} ^sub.domain.to/q5$ [NC]
RewriteRule ^(.*)$ https://sub.domain.to/full-q [R=301,L]
2
Answers
ok it worked when I added
%{REQUEST_URI}
so this worked
The
HTTP_HOST
server variable contains the value of theHost
HTTP request header, ie. the hostname only. This does not contain the URL-path (ie./q1
and/q2
in your example).The
RewriteRule
pattern matches against the URL-path.Try the following instead:
Or, use the
REQUEST_URI
server variable in a condition, which contains the full URL-path. For example:Test with a 302 (temporary) redirect to avoid potential caching issues and only change to a 301 (permanent) redirect – if that is the intention – once you have confirmed this works as intended.
You will need to clear your browser cache before testing.