Htaccess Redirect specified url with path to other url

mrfizh

I want redirect url to other url in the my website.

staging.mydomain.com/pathurl/

to this one :

staging.mydomain.com/newpathrul/

and I tried to add in httaccess file in my root project folder with this code :

RewriteCond %{HTTP_HOST} staging.mydomain.com/pathurl/ [NC]
RewriteRule ^/?$ "staging.mydomain.com/newpathrul/" [R=301,L]

but it's not work, could you tell what the correct htaccess code to redirect specified url with path to other url.

Ben

The HTTP_HOST Variable only has the host part, but does not have the path part.

RewriteCond %{HTTP_HOST} ^staging.mydomain.com$ [NC]
RewriteRule ^pathurl/(.*)$ /newpathurl/$1 [R=301,NC,L]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related