i'm trying to implement a partial url redirect to htaccess.
The URL should be redirected from:
hs.bzb.domain.com/bzbwebprod/login?rout=modeDeta&mode=654321&arti=&farb=4321
to:
bzb.domain.com/bzbwebprod/#/login?rout=modeDeta&mode=654321&arti=&farb=4321
But the best would be if the snippet
hs.bzb.domain.com/bzbwebprod/login?
would be redirected to
bzb.domain.com/bzbwebprod/#/login?
with the queries (e.g. ?rout=modeDeta&mode=654321&arti=&farb=4321 ) it comes with.
Tried:
RewriteEngine On
RewriteRule ^hs.bzb.domain.com/bzbwebprod/login?* bzb.domain.com/bzbwebprod/#/login?$0 [L,NE,NC,R=301]
Since i don't have much experience in htaccess, i was just reading other topics with solutions and was trying my best on https://htaccess.madewithlove.com/ to find the right options.
Can someone lend me a helping hand in it?
The rewriting attempt you show in the question mixes requested host and path in the matching pattern of the RewriteRule
. That won't work: the documentation clearly states that such rules are applied against the path of the request only. You need a RewriteCond
to test the requested host name.
You are probably looking for something in this direction:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^hs\.bzb\.domain\.com$
RewriteRule ^/?bzbwebprod/login$ https://bzb.domain.com/bzbwebprod/#/login [R=301,L,QSA]
You can implement that rule in the central http server's virtual host configuration. Or, if you do not have access to that (read: if you are using a cheap web hosting provider), you can instead use a distributed configuration file (often called ".htaccess") located in your virtual host's DocumentRoot
folder.