apache.htaccesshttp-redirectmod-rewritelitespeed

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.


Solution

  • I figured it out!

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