Search code examples
apachesubdomainhttp-redirect

Redirect www.example.com/blog to blog.example.com on other server


I have two ec2 servers in which one is running my website and another is blog with sub-domain. Both are having apache2 installed.

How can i redirect http://www.example.com/blog to blog.example.com ?


Solution

  • You can use mod_rewrite.

    Create .htaccess file in root containing

    RewriteEngine On 
    RedirectMatch 301 ^/blog http://blog.example.com/