Page 1 of 1

total noob - trying to redirect parked domains to subfolders

New postPosted: 11 Jul 2008 15:00
by marksteven
Hi,

I hope I make sense when I say that I have a domain registered, with hosting and a few pages on there. I have also parked a couple of domains - meaning that when a user types, for example, http://www.parked-domain.com they get the index page for the main domain. However, I'd like the following:

When a user requests http://www.parked-domain.com they are actually directed to a subfolder of the main domain and are able to navigate within that subfolder, as if it were a seperate site.

I have managed to use the following code (cobbled together from info on the web) to make it so that a certain page is shown when the parked domain is requested. When I try and create links from this page (which displays OK) they don't work - all I get is the original subfolder page (bbindex.htm), but the URL shown is that of the page that the link was for.

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.parked-domain.com$
RewriteRule ^(.*)$ bbindex.htm [L]

Is there any way to get the behaviour I want?

I thought that this should work:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.parked-domain.com$
RewriteRule ^(.*)$ /subfolder/ [L]

But I get a "500 server error"

I have the .htaccess file in the root (www) folder of my site. I am only using plain old HTML for the pages.

many thanks for any help,

Mark

Re: total noob - trying to redirect parked domains to subfolders

New postPosted: 11 Jul 2008 16:53
by marksteven
replying to myself...

I found this solution:

Options +ExecCGI
RewriteEngine On
RewriteBase /

# if the internal redirect in the 2nd rewriterule works this
# rule stops the rewriteengine from looping continually
RewriteCond %{ENV:REDIRECT_STATUS} ^200.*
RewriteRule ^ - [L]

# the http_host is http://www.example.com or example.com or
# example2.com etc. This grabs whatever is before the .com
# and after the www. so it will be example or example2 or example3
# and puts that in the variable %2. so this redirects internally requests
# example.com-> from / -> /example/
# example2.com-> from / -> /example2/
# example3.com-> from / -> /example3/
# example4.com-> from / -> /example4/
#
# so a request for example3.com/test/index.html is served from
# /var/vhosts2/henrik/public_html/example3/test/index.html
RewriteCond %{HTTP_HOST} ^([a-z]+\.)?(.+)\.[a-z]+$ [NC]
RewriteRule ^(.*)$ %2/$1[L]

It works a treat. I just had to create subfolders for each domain (main and parked) and put different index.htm files in each

:)