Redirect your root directory to a subdirectory


Depending on how your site is constructed, it may be necessary to redirect requests for the primary URL to a subdirectory. For example, requests to could go to This is most often necessary with WordPress.

When installing a DreamHost WordPress install:

  • The target directory must be completely empty to succeed.
  • For example, if you want to put the installation in the directory /, this directory must be empty and contain no files.
  • Another solution is to install the software into an empty subdirectory such as; then, you could create rules in an .htaccess file to automatically redirect requests for to

Creating an .htaccess file on your DreamHost web server

View the following article for instructions on how to create an .htaccess file on your web server:

If the file already exists, view the following articles for instructions on how to update it (depending on if you're using an FTP client or SSH):

What to change in the examples below?

The examples below can be entered into your .htaccess file exactly as shown.

Only if the example contains a URL in bold should you change that to your actual URL. For example, if you see the domain, change this to your own domain name.

Redirect requests with .htaccess

Redirect "ALL" requests to a domain to a subdirectory

You can redirect all requests to a subdirectory by adding an .htaccess file to the root of your domain’s directory:

  1. Visit the FTP page for instructions on how to upload.
  2. Once connected, upload (or create) a text file named .htaccess (with no extension).
  3. Make sure it’s uploaded to your domain’s directory such as
  4. Add the following content to this .htaccess file:
RewriteEngine on
RewriteBase /

# Rewrites all URLS without blog in them RewriteCond %{REQUEST_URI} !^/blog/ # Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)] RewriteCond %{HTTP_HOST} ^(www\.)?example\. # Rewrite all those to insert /folder RewriteRule ^(.*)$ /blog/$1 [L]

This example redirects all requests for a website automatically to a subdirectory named /blog. If you need to redirect to another directory, just change the two references of /blog to your subdirectory.

Redirect "ONLY" the domain's root URL to a subdirectory

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

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

Redirecting in WordPress

The redirect feature is included in WordPress. Visit their codex page for instructions on Giving WordPress Its Own Directory.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?