skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    I figured it out!

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

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

        RewriteEngine On
    
        RewriteRule ^/a-path/$ https://blog.myname.com/this-path/ [L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search