Htaccess Redirect From subdirectory to subdomain


Use htaccess, you can redirect a subdirectory to subdomain, for instance: http://www.mydomain.com/info to http://info.mydomain.com.

In the example below, anything at highub.com/blog will be redirected to blog.highub.com:

Options -Indexes +FollowSymLinks

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^highub.com [NC]
RewriteRule ^(.*)$ http://www.highub.com$1 [L,R=301]

RedirectMatch 301 ^/blog/(.*)$ http://blog.highub.com/$1

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  1. #1 by Ahmadreza on May 26, 2010 - 12:48 pm

    Tanx A Lot
    i Use This Code And it’s Working Very Well.

    But a Little Problem:

    if i Type The Adress Without www it will redirect to home page instead of subdoman

    e.g. highub.com/blog (without www)

    Plz Help Me To Solve This Problem

(will not be published)