Knowledgebase


Portal Home > Knowledgebase > Hosting FAQ's > How to redirect domain to subdirectory without redirecting url

How to redirect domain to subdirectory without redirecting url

f you want to redirect your domain name to sub-directory but the url shows only domain name

For example :

http://yourdomain.com redirect to http://yourdomain.com/blog but the URL shows only http://yourdomain.com

Then add the following rules in your .htaccess file.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain.com
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]
RewriteRule    ^$   blog/    [L]
RewriteRule    (.*)  blog/$1 [L]
</IfModule>

It is easy but to perform this task you need to consider one of the hostripple web hosting plans and then edit or upload a .htaccess file from your file manager or SSH access on your cPanel hosting plan or a Linux Dedicated Server or the linux VPS hosting plan.


Also Read