How to redirect root directory ("/")



Does anyone know if it’s possible to redirect a root directory via the control panel?
ex. ->

I get errors in the control panel when I attempt to do this (it tells me that it can’t redirect a directory within the same domain)

Also, when I tried to “re-map” the directory, the application I installed under /blog didn’t work anymore (WordPress).

Basically, my objective was to create a WordPress blog in /blog without using up the root directory of my subdomain. However, I also wanted the subdomain to point to my blog until I determine the application that I’ll be installing at the root directory.

Hope someone can help!


Well, in case someone else has run into this issue…
My work-around was to put an index.html page under my root directory.
Then I just added HTML content with a redirect tag:


My Title [/color]


Another option would have been to create a .htaccess file in your root to redirect the request.

Something like…

[color=#0000CC]redirect 301 /index.html[/color]


[color=#0000CC]DirectoryIndex /blog/index.html[/color]


Save [color=#CC0000]$50[/color] on DreamHost hosting using promo code [color=#CC0000]SAVEMONEY[/color] ( Click for promo code details )


Using a “Refresh” directive from an HTML document is evil: it makes going back difficult, and a robot would have a hard time knowing that the document is intended as a redirection.

Raz’ suggestion is good, though I would use a 307 status code for the redirect, since it’s pretty clear from our above posting that it’s a temporary measure.

I’m not sure exactly what action Apache would take with the DirectoryIndex directive given such a value, though.

(Aside: The 302 status code is more common in these kinds of circumstances, but I believe 307 is more proper in this particular case. According to HTTP/1.1, the only difference in semantics between 302 and 307 is that 307 redirections are expected to be handled with the same request method as the original request, whereas 302 is ambiguous. Me being the stickler I am, though, have come to the conclusion that 302 should be used in cases where a document will -always- be located somewhere other than the original request, but not always the same place (eg. /news/ may redirect to /news/jan/ one month and /news/feb/ the next); and 307 is used in such cases where a document is simply elsewhere for the time being, but will be returning to its original location (as seems to be the case here). Of course, this conclusion is based solely on the advisory names of the statuses (“Found” and “Temporary Redirect” respectively) and otherwise has very little basis in reality. :slight_smile: )


Good call. On reflection a 302 or 307 code to signify a temporary move would definitely suit the circumstances better.

I wasn’t completely sure this would work either, but I just tried it and it seems to have the expected result (at least it does on my particular Apache install).


Save [color=#CC0000]$50[/color] on DreamHost hosting using promo code [color=#CC0000]SAVEMONEY[/color] ( Click for promo code details )


I’m now using the .htaccess redirect.

Since there’s no client-side content that goes with the redirect method, it seems to be working faster as well.

Thanks for your help and suggestions!


with wordpress, you can just set up a front page in your root, create an index.php and add these 4 lines…

<?php define('WP_USE_THEMES', true); require('./blog/wp-blog-header.php'); ?>

and thats it, your blogs main page gets pumped into that page on the root.

Search for “static front page” for more info.