Luke S
Luke S

Reputation: 1

How do I redirect a path to another path on another domain for only a given domain?

I would like to redirect myname.me/a-path to blog.myname.com/this-path/. The directory that serves myname.me also serves myname.com. I do not want myname.com/a-path to redirect to blog.myname.com/this-path/.

I have tried several things with mod_rewrite and most recently have tried the following.

RewriteCond %{HTTP_HOST} ^myname\.me\$
RewriteRule a-path https://blog.myname.com/this-path/  [L,R=301]
RewriteCond %{HTTP_HOST} ^myname\.me\$
RewriteCond %{REQUEST_URI} ^/a-path
RewriteRule https://blog.myname.com/this-path/  [L,R=301]

I appreciate any help.

Upvotes: 0

Views: 29

Answers (2)

Jordy
Jordy

Reputation: 82

This is how I redirect to a subdomain within the same host.

    RewriteEngine On

    RewriteRule ^\/a-path\/$ https://blog.myname.com/this-path/ [L]

Upvotes: 0

Luke S
Luke S

Reputation: 1

I figured it out!

RewriteCond %{HTTP_HOST} ^myname.me$
RewriteCond %{REQUEST_URI} ^/a-path         
RewriteRule ^(.*) https://blog.myname.com/this-path/  [R=301,L]

Upvotes: 0

Related Questions