Redirect Fully Hosted

With my former host I was able to redirect a fully hosted site. How do I do that with Dreamhost?

This is what I need:
to redirect here:

While at the same time the sub-folders in will serve any files so that I can point to this:

Thank you.

You could just create an index.php file with this code in it:

<?php header("HTTP/1.1 301 Moved Permanently"); header("Location:"); exit; ?>

That will only redirect if that page is called, but you can still load images or access files in other directories.

:stuck_out_tongue: Maximum savings promo code: MaxSavingsAtDH

I don’t know if you can do both of those… However you could redirect > myspace and… But I think you would get a 404 error or something if you tried to do because that doesn’t exist where points to…

Look under Redirected Settings and then you would want to create a subdomain for the stuff you want hosted locally.

Thank you seiler!

Excellent clean and simple workaround!

I also placed that same file in the subdirectories to prevent directory browsing and so far it works: I can still retrieve the files within the subdirectories.

Two birds with one php page!

Thanks again. :slight_smile:

If you just needed the root to be redirected, instead of using PHP you could have used an Apache directive:

RedirectMatch ^/$

:cool: -//- One-time [color=#6600CC]$50.00 discount[/color] on [color=#0000CC]DreamHost[/color] plans: Use ATROPOS7

Thank you Atropos7,

Questions to you:

  1. I have never used Apache directives, would you please provide step by step instructions on how to do that?

  2. Is your solution better/cleaner than seiler’s, and if yes why?

  3. And, if I were to implement your solution, what else should I do to avoid directory browsing? (My guess is that you would suggest to add Options -Indexes in htaccess, but I have never used htaccess either and would need step by step instructions on that too.)

Just learning here. Even though I implemented seiler’s suggestion I may need yours in the future or for a different site. Or someone else may need it…


You upload a text file named .htaccess that contains directives. The directives will be applied for the subdirectories as well. Make sure the text file is uploaded as ASCII/text mode when using FTP.

The directives are documented here: Apache 2.2 Directive Index

Each directive has a “Context” property and if it says “.htaccess” you can use that directive in an .htaccess file.

Well it doesn’t require loading PHP for each request just to send a redirect. If you had a busy site you would avoid using PHP for such a trivial matter.

You just add that directive to the .htaccess file as well.

:cool: -//- One-time [color=#6600CC]$50.00 discount[/color] on [color=#0000CC]DreamHost[/color] plans: Use ATROPOS7

I see…

So do you mean this?

  1. Open Notepad

  2. Add this text in it:

RedirectMatch ^/$
Options -Indexes

  1. Save as:


  1. Simply FTP the .htaccess.txt file into the directory to replace the php file with it (and remove all the php file copies from the subdirectories).
    And “Make sure the text file is uploaded as ASCII/text mode when using FTP”

Or not?

Another question for you: is this solution as search engine friendly as the php solution?

If it’s that simple you just opened me up to a whole new world of possibilities with Apache directives…

Thanks again!

That will not produce the desired results.

You ultimately need to end up with a file named “.htaccess” (note the two "s"s and the absence of the “.txt” extension).

Since “notepad” likes to add that “.txt”, if you are going to use notepad you should either rename the file before you upload it or rename it on your server after uploading.


This works perfectly:

Create a simple text file (I used Notepad++) with this in it:
RedirectMatch ^/$
Options -Indexes

Save as:


That takes care of forwarding and blocking direct access to directories.

The only weird thing is that the file disappears after uploading it. I use Core FTP LE, maybe it’s a bug.

Thank you all!

Yep! Te combination of spelling “.htaccess” correctly, and using notepad++ should produce the desired results! [wink[. I’m glad you got it working!

The file hasn’t really “disappeared”, it’s just a “hidden” file (note the “.” that begins the filename).

Most FTP clients have an “option” or “preferences setting” to enable display of such “hidden” files. If you check your CoreFTP LE documentation carefully, you may find such an option available for you.