Forum Moderators: phranque

Message Too Old, No Replies

.htaccess, parked domain, and redirection

How does it really work?

         

kenchix1

2:44 am on Apr 11, 2006 (gmt 0)

10+ Year Member



I'm a bit confused on how the .htaccess works on parked domains.

I have 2 domain names let's say

1.) webmasterworld1.com
2.) webmasterworld2.com

the .htaccess redirection works perfectly with the first domain however, visitors landed on the wrong page if they use the 2nd domain.

I have a catch-all subdomain and based on the subdomain that was entered, the a scripts redirects them to its appropriate page.

my code for both domains are the same:

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{REQUEST_URI}!^/mypage\.php
RewriteCond %{HTTP_HOST}!^www\.webmasterworld1\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.webmasterworld1\.com
RewriteRule .* [webmasterworld1.com...] [R]

RewriteCond %{REQUEST_URI}!^/mypage\.php
RewriteCond %{HTTP_HOST}!^www\.webmasterworld2\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.webmasterworld2\.com
RewriteRule .* [webmasterworld2.com...] [R]

any suggestion how it will work?

thanks in advance.

jdMorgan

3:03 am on Apr 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This all depends on exactly what you mean by the (non-technically-specific) term "parked."

Different parking services do it differently. If they are redirecting the second domain to the first domain, then HTTP_HOST will never indicate the second domain, since the parking service redirect will have already changed it before it ever reaches your server.

The first step is to check out your parked domain URLs using a server headers checker, and see exactly what mechanism is used to forward the traffic to your server. It's most likely a 301 or 302 redirect.

Note that you could always simply change the DNS for the parked domain and point it to your server, as long as your host will allow this and set up the server config to recognize requests for the second domain and pass them to your first domain's filespace.

I don't use parking, as I see it as an unnecessary complication.

Jim

kenchix1

3:31 am on Apr 11, 2006 (gmt 0)

10+ Year Member




The first step is to check out your parked domain URLs using a server headers checker, and see exactly what mechanism is used to forward the traffic to your server. It's most likely a 301 or 302 redirect.

I'm sorry, but I don't fully understand it. I parked the second domain using the CPanel Parked Domain.


Note that you could always simply change the DNS for the parked domain and point it to your server, as long as your host will allow this and set up the server config to recognize requests for the second domain and pass them to your first domain's filespace.

the host say something about wildcard DNS and dedicated IP for the the .htaccess for the redirection to work. Though the redirection script in .htaccess worked on the first domain, but it wont work on the second domain.

the second domain seems to ignore (or probably remove) the parameters that PHP is passes to it which is on this line header("Location:http://".$_SERVER['HTTP_HOST']."/index.php?a=6&b=$userid");

thanks for the reply sir.

[edited by: jdMorgan at 3:17 pm (utc) on April 11, 2006]
[edit reason] Formatting [/edit]

jdMorgan

2:03 pm on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll have to determine where the files for the second domain are expected to reside. The redirect code has to be in that filepath in order to be invoked.

I'd assume that the second domain name resolves to your server, as long as you're not getting DNS-related failures when trying to browse to that domain, but basically, you need to check every step to be sure.

  • DNS must resolve the second domain to your server.
  • Your server must resolve that hostname to your filespace.
  • The redirection code must reside in the correct directory path within that filespace.

If those three requirements are met, then you should be able to get this working.

Jim