How to redirect domain directly to subdirectory without redirecting url

Sometimes the simple things are the hardest to figure out and today we are going to show you a simple way to redirect your primary domain to a subfolder on that domain. For the purposes of this tutorial it will redirect to a subfolder at /blog. This is useful if your WordPress blog is installed to a subfolder and you want the main domain to forward to it.

In your public_html folder (also called the “www” folder), you need to create a file called .htaccess. From this file we are going to use a few lines to redirect those requests in a search engine friendly way.

Add the following lines to that file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?YourDomain.com$
RewriteRule ^(/)?$ blog [L]

The only change you need to make is to change “YourDomain.com” to your domain. This will then redirect everything from the domain to the folder /blog at that domain. If you want to change that folder just edit the “blog” part.

And you are good to go!

  • 30 Los Usuarios han Encontrado Esto Útil
¿Fue útil la respuesta?

Artículos Relacionados

How do I use PHP 4 or 5?

All of our servers comes with PHP 4 and 5 installed. To select what version you would like to...

500 Error

If your site occurs a 500 Internal Server Error the most common are php settings in your...