Forum Moderators: phranque
Now I also have the example.de (for germany) domain registered and want this to go straight to the german language version and prices in Euros.
So the URL to switch would be example.com/index.php?language=2¤cy=2
Basically if I add?language=2¤cy=2 on the end of every page it produces the result. I could use php or a straight redirect page but I want the search engines to READ german when they go to example.de - so each site gets indexed independently I hope. (they do have different content!)
Can I do this with .htaccess? I guess I want
example.de to show the contents of example.com/index.php?language=2¤cy=2, and of course all the other pages produced by the site.
I have dedicated server so lots of control - just dont know what I am doing! Thanks :-)
It seems like the site "remembers" your settings once you have gone past this index page.
Obviously some pages get longer such as:
[example.com...]
(the above includes a session URL for when cookies are disabled).
or simpler with cookies such as:
[example.com...]
I am confused as to whether I need to use:
1. DirectoryIndex command
2. Proxypass
3. Rewrite
Sounds like Proxpass might be something like what I need? Because in effect I want example.de to serve up results from example.com
In my dream scenario I would host each domain "locally" (e.g. the .de on a German server), and pull the pages from the main site. This would probably keep the engines happiest!
In other words I would have public_html/_com and public_html/_de and the domain names would simply be pointed at the relevant sub-directories (though I'm not sure what technique they use for this).
Are your EN and DE sites totally separate content? Pressuanbly not, so what do they share (eg.identical images and identical structure)?
If so (and using my set up above) I would have to duplicate the structure (or have this built into a database - which means the actual page names would be identical) and share the images directory. I would probably also have a single database of items for sale (if that's what you're doing) and have values and currency codes against each item (or a formula with rounding).
To the outside world the sites would have identical structure with images in identical places but text would be completely different (but in identical places). This is what you want I guess?
Sorry if I'm straying off the topic - or stating the bleeding obvious - it's an area I've become a little interested in lately hence my interest here.
Jim - if you're there - is there a post that goes into this or a how-to guide for internationalisation using apache?
I did a quick search and found this [vancouver-webpages.com] but I'm not sure if it addresses the multiple domain name topic - only had a quick look.
If you do find a good resource can you let me know please?
Then use mod_rewrite to rewrite (not redirect) any request for pages in the .de domain to the same page, but with the "?language=2¤cy=2" query string appended.
In simplified form, an example for .php pages would be:
RewriteCond %{HTTP_HOST} \.de(:[0-9]{1,5})?$
RewriteRule ^(.+)\.php$ /$1.php?language=2¤cy=2 [L]
Jim
Looking at the way my site operates it might be in fact that I only need/want to redirect the very first index page.
So I need I think example.de to go to example.com/index.php?language=2¤cy=2
but from there looks like I only need to change the first part of the URL (from .com to show .de)
I have been trying to read up on this the last few days but it still feels like Egyptian to me at this stage (but I did get some basic commands working on a test site).
Thanks so far!
Yes, point the domain to the IP address -- forget all that "parking" and "frame-forwarding" stuff if you want a happy life -- or good search enigne ranking! :)
The typical approach would be to structure the site like this:
Point all top-level-domain/country-code domains to the server IP address.
Detect the country code in the domain name, and pass that to a (new) script as a parameter.
New script looks up the correct language and currency parameters and passes that to the original script.
For a small site with just a few tlds and country-codes, you can do it all with mod_rewrite:
RewriteCond %{HTTP_HOST} example\.de
RewriteRule ^(.+)\.php$ /$1.php?language=2¤cy=2 [L]
RewriteCond %{HTTP_HOST} example\.co\.uk
RewriteRule ^(.+)\.php$ /$1.php?language=3¤cy=2 [L]
RewriteCond %{HTTP_HOST} example\.com
RewriteRule ^(.+)\.php$ /$1.php?language=4¤cy=3 [L]
RewriteCond %{HTTP_HOST} example\.fr
RewriteRule ^(.+)\.php$ /$1.php?language=5¤cy=2 [L]
Jim
RewriteEngine on
RewriteCond %{HTTP_HOST} \.co\.uk(:[0-9]{1,5})?$
RewriteRule ^(.+)\.php$ /$1.php?language=1¤cy=1 [L]
The .co.uk is directing to the IP number correctly, but I get a 500 Internal Server Error, plus it says a 404 error was found!
The example.biz 1st page is index.php but this is the content of the php file if that matters at all:
<?php
include("static/includeBase_front.php");
$xSec=1;
$thisTemplate = "index.html";
dbConnect($dbA);
include("routines/cartOutputData.php");
$tpl->showPage();
$dbA->close();
?>
Firstly I want example.co.uk just to show the contents of example.biz for every page.
So if you go to say example.co.uk/mypage.php you SEE the results from example.biz/mypage.php (so straight switch of the 1st part of the URL only) - but stays as example.co.uk/mypage.php in the browser.
Then secondly just for that first index.php page I need?language=1¤cy=1 added on the end. (I think once changed at the homepage the cookie or session ID remembers from there on).
So when someone goes to example.co.uk it really displays the page contents from example.biz/index.php?language=1¤cy=1
I honestly have tried to read the Apache guides, and I am not generally daft, but things like ^(.+)\.php$ just completely lose me!
Thanks,
Jonathan.
What does your server error log say? That's the first place to look when you get a server error.
You may need to add Options +FollowSymLinks to your code to enable mod_rewrite.
If "^(.+)\.php$" loses you, then review the regular expressions tutorial cited in our forum charter. Regular expressions form one-half of the foundation you'll need to use mod_rewrite successfully, and there is no use trying to go forward without being comfortable with them.
To get you started, "^(.+)\.php$" means "a string starting with at least one character, followed by a literal period, and ending with "php". The parentheses tell mod_rewrite to remember the contents from the start of the string up to the literal period, so that this information can be used (back-referenced) by the substitution URL (in other words, remember that part of the requested URL so that we can "copy" it into the new URL). The "\" marks the period that follows it as being a literal period, instead of being a "special" character that regular-expressions defines as meaning "any single character".
The learning curve is admittedly quite steep on this stuff. For one thing, complex regular expressions are much easier to write when you know the desired goal than they are to read when you don't. But once you gain basic understanding of mod_rewrite, you will realize how immensely powerful a tiny bit of good mod_rewrite code can be -- and how terribly destructive a tiny bit of bad code can be, too.
Jim