Redirect only the domain's root URL to sub-directory with URL masking (.htaccess)

The following example provides an alternative method of transparently redirecting. It works with any sub-domain (including root/naked domains) and only transparently redirects a root request, while allowing directly requested sub-directories like example.com/other to be accessed.

 

=======================

RewriteEngine on

RewriteCond %{HTTP_HOST} example\.com [NC]

RewriteCond %{REQUEST_URI} ^/$

RewriteRule ^(.*)$ /blog/$1 [L]

=======================

Add Feedback