Forum Moderators: phranque

Message Too Old, No Replies

Using .htaccess to map root to subdirectory

         

technetium

1:40 pm on Mar 30, 2009 (gmt 0)

10+ Year Member



I'd like to do something that I believe is simple, but without having much experience with writing .htaccess files, is turning out to be very confusing for me.

I have been testing drafts of a site, so right now all my live files are in the root directory for the domain. Let's call it domain.com.

I should soon be wanting to replace the live site with the content located in domain.com/draft5.

The content is static html, and my subdirectory structure isn't changing, so I don't need to do any redirecting in that way.

I'd just like to make it so that when the user types in domain.com, they see the content that's located in the draft5 directory, without seeing draft5 in the address bar. I think mapping is the term I'm looking for here.

Some content is in subdirectories, so if they're viewing or linked into domain.com/press, they should see content physically located at domain.com/draft5/press, and so on.

I would like to, at the same time, redirect all requests for anything at [domain.com...] to be 301 redirected to [domain.com...] Just getting rid of the www sitewide.

Any help with my headache will be hugely appreciated. Thank You.

solutionc

2:39 pm on Mar 30, 2009 (gmt 0)

10+ Year Member



I think you will find what you are looking for here;
<snip>

[edited by: jdMorgan at 5:29 pm (utc) on Mar. 30, 2009]
[edit reason] No URLs, please. See Terms of Service and Charter. [/edit]

g1smd

3:08 pm on Mar 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



if you have access to httpd.conf you can set the site root folder to be whatever you need in there.

If you only have access to the .htaccess file, then you can do a simple site-wide rewrite of simple URLs to the draft folder.

The www and non-www issue can be fixed with a simple site-wide 301 redirect, code for which is posted somewhere in this forum almost every day.

jdMorgan

5:30 pm on Mar 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




RewriteCond $1 !^draft5/
RewriteRule ^(.*)$ /draft5/$1 [L]

Jim

technetium

8:25 pm on Mar 30, 2009 (gmt 0)

10+ Year Member



JD, you are the man!

Thanks to all for the help. In the end, those 2 beautiful little lines did the trick.

I'm going to have to devote some time towards learning this in more detail.

Thanks again,
Chris