Redirect subdomain to domain with .htaccess in domain directory


My webpage used to be blog.example.com, but it is now example.com. I had to delete the /blog directory (where the website hosted blog.example.com), because I have a Wordpress page at the URL example.com/blog and that screws it up.

I have tried:

RewriteEngine on RewriteCond %{HTTP_HOST} ^blog\.example\.com RewriteRule ^(.*)$ http://www\.example\.com/$1 [L]

As well as:

RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?blog\.example\.com$ [NC] RewriteRule ^ http://www.example.com/%{REQUEST_URI} [NE,R=301,L]


RewriteEngine on RewriteCond %{HTTP_HOST} ^blog\.example\.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

But none of these make any difference in the subdomain. <strong><em>What can I do to redirect blog.website.com/URLS to website.com/URLS?</em></strong> (without creating example.com/blog because it will mess up Wordpress's webpage website.com/blog)


I figured it out! I had to:

<ol><li>Remove the redirect from bluehost that was supposed to redirect the subdomain to the main domain</li> <li>Create the subdomain blog.example.com at the directory at public_html/blog-redirect</li> <li>

Add this redirect code to the .htacces file under /blog-redirect:

RewriteEngine On RedirectMatch 301 ^/(.*)$ http://example.com/$1 </li> </ol>


  • How to set a URL rewrite for sub-domain links like these?
  • Multiple conflicting htaccess RewriteRules
  • .htaccess not working on codeigniter subdomain & directory install
  • Redirect from few url's (both www and non-www) to original one
  • Allow from env with mod_rewrite not mod_setenvif in .htaccess
  • Redirect site with .htaccess but exclude two+ folders
  • mod rewrite subdomain to folder break paths to css and images
  • Add rewrite rule
  • htaccess mod_rewrite - Trailing Slash and loop of redirects
  • SilverStripe. How to redirect from www.domainName to domainName?
  • Why I am getting 'Forbidden' when I try to login on my live codeigniter site?
  • htaccess mod_rewrite URL within subfolder
  • Redirect only with specific domain
  • .htaccess mod_rewrite Unknown number of Variables of a GET form
  • Codeigniter 2.1.4 installation in sub directory
  • How can I .htaccess 301 redirect all pages/files (except for one) to new domain?
  • Mod_rewrite: Include query string when redirecting
  • How to escape “?” using regex in .htaccess for mod_rewrite
  • url rewrite not working .htaccess
  • Use htaccess to mask domain and folder name
  • Too many Redirects after switching WordPress to https
  • Htaccess Public Folder Rewrite Rule
  • Can I used mod_rewrite to change file extensions? .jpeg to .jpg for example
  • Can't access my folder because of WordPress [closed]
  • Change URL in browser without redirection with htaccess
  • .htaccess rewrite: subdomain as GET parameter and filepath afterdomain intact
  • Smart URL with optional parameters?
  • Help with mod_rewrite
  • htaccess settings for angularJS pushstate
  • Removing the .php file extension from the URL Request
  • Mod rewrite redirection to another domain if file not exist
  • Apache RewriteRule redirection with url encoded
  • htaccess add www if not subdomain, if subdomain remove www
  • htaccess rewriting URLs with multiple forward slashes
  • Python - Map / Reduce - How do I read JSON specific field in using DISCO count words example
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • bootstrap to use multiple ng-app
  • How to get icons for entities from eclipse?
  • Turn off referential integrity in Derby? is it possible?
  • JaxB to read class hierarchy