Forum Moderators: phranque

Message Too Old, No Replies

Dynamically load pages based on domain name

         

Quarfelburg

6:38 pm on Dec 2, 2003 (gmt 0)

10+ Year Member



I have two sites - mysite.ca and mysite.com

When Canadians visit mysite.com they are immediately redirected to mysite.ca

Likewise, when Americans visit mysite.ca they are redirected to mysite.com

The two sites are ALMOST identical minus about 10 pages, and the redirection works like a charm. However maintenance is more of a pain than it should be, as when I make a change to one site I have to make the identical change on the other site.

What I want to do is this - code my site such that the pages that are NOT IDENTICAL will be dynamically loaded and delivered based on the users country code. That way I will only need to make changes to one page when editing my site (as opposed to 2).

My question is two fold:

1)Is this search engine friendly?
2)Is this difficult to do in PHP?

Cheers,
Hayden

danieljean

12:22 am on Dec 3, 2003 (gmt 0)

10+ Year Member



Hi Hayden,

I'd love to hear what people will say about the search-engine implications, since I'm in the same boat with a couple different sites.

As for the implementation, that's pretty trivial in any scripting or programming language, including PHP - assuming you really know the users' locale.

What I found annoying is that some users actually have their locale set as en_US instead of en_CA. This seems to happen a lot with Mac users and Mozilla browsers. I am considering using IP addresses, but even that is not foolproof, so there has to be a way to let people go from one site to the other :(

Quarfelburg

4:44 pm on Dec 4, 2003 (gmt 0)

10+ Year Member



I use an Apache mod called GeoIP, and it is surprisingly accurate. I've been using it for about 6 months now, with hardly any US users seeing the .ca site, or Canadian users seeing the .com site.

If you want me to sticky you the url I will.

danieljean

5:54 pm on Dec 4, 2003 (gmt 0)

10+ Year Member



Thanks, I was considering the same package, but just haven't installed it yet.

There still remains a problem that it's not 100% accurate- and even less so if you need sites that are more internationalized than just US/CAN. Some ISPs have IP addresses that can be used in multiple countries.

Also, if I can't change it from the page, debugging it becomes annoying- I have to make sure the currencies are correct :)

DaveAtIFG

11:43 pm on Dec 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



1)Is this search engine friendly?
2)Is this difficult to do in PHP?

This is effectively cloaking, regardless of the reason it's done or the intent behind it. As such, Google may penalize or ban the site IF they become aware of it. Ink will probably ignore the cloaking. SEs are most likely to become aware through a spam report, commonly provided by competitors in a competitive industry. If your industry is not too cutthroat, you'll probably be fine.

I speak a little "pigeon" PHP and so can't comment meaningfully on question #2. I have seen posts indicating that people are frequently redirecting and cloaking using PHP. AFAIK, a page must be named with a .php extension in order to be parsed for PHP code. If that's the case, it may mean renaming pages and losing some traffic until the "new" pages are indexed.

Quarfelburg

4:56 pm on Dec 5, 2003 (gmt 0)

10+ Year Member



I could always just do a 301 redirect for the currently indexed pages so traffic loss shouldn't be a problem.

The other way that this could be done would be to put the 10 or so pages that are different in separate folders and create individual .htaccess files for them. Would this option be more viable?

My knowledge of .htaccess is limited but is it possible to just refer to these pages in my current .htaccess?

DaveAtIFG

5:05 am on Dec 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ink doesn't follow/reindex 301s so traffic loss could become a problem soon.

This can be done in .htaccess but it's better done with a scripting solution. With an .htaccess solution, you'll use mod_rewrite and geolocation becomes awkward because you'll need to screen by IP or do a DNS lookup.

There's a recent thread about it here somewhere but I can't find it! :(

Quarfelburg

4:02 pm on Dec 8, 2003 (gmt 0)

10+ Year Member



I am already using mod_rewrite for in my root .htaccess to redirect to .ca and .com and it had been working well for months. So I don't see why just targetting the individual pages could hurt me. Plus this would remove the need for a .php extension and 301's.

DaveAtIFG

4:10 pm on Dec 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Agreed!

I am already using mod_rewrite for in my root .htaccess to redirect
Why didn't you just say so!?! ;)

The winking smiley means I'm teasing you. I AM teasing you.

Quarfelburg

4:20 pm on Dec 8, 2003 (gmt 0)

10+ Year Member



Lol, I thought it was implied. Anyways, now I just have to figure out how the heck to do it! Last time Jim helped me =)

So is this possible to do within my root htaccess? Just specify the filename that will deliver different pages?

For example, let's say that the virtual include footer.txt is something I want different for the Canadians and Americans. But EVERY other file on my site is identical). Can I just put that in my root .htaccess?

Here is my current code (redirects canadians to .ca):

RewriteEngine on

RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CA$
RewriteCond %{HTTP_HOST}!^www\.mydomain\.ca$
RewriteRule ^(.*) [mydomain.ca...] [R=301,L]

RewriteCond %{HTTP_HOST}!^www\.mydomain\.com
RewriteRule (.*) [mydomain.com...] [R=301,L]

[edited by: DaveAtIFG at 4:24 pm (utc) on Dec. 8, 2003]
[edit reason] No specifics please [/edit]