Domain redirect using .htaccess

I hope someone can help me with the terminology for this as I’m not even sure what to search for :confused:

My website is localized: you can view it in Dutch or English. The problem is my website doesn’t show a different URL when you switch between languages (yeah I know it’s a crap site because of that but believe me, I can’t change it because it’s highly customized to my business needs). I need language specific URLs for marketing and SEO purposes.

My site uses a .com address and I also have a .nl domain.

Can I use a .htaccess file to manipulate the use of language specific URLs with the country-specific domain? Hope that makes sense!

ninja,

What you’ve said is that it’s the visitor who selects the language (on the page itself) so, IMHO, you have no problem at all. Just build the language into the scripts that you link to in your different advertisements.

Regards,

DK

ninja,

We’re sneaking up on how it’s being done! Select statement to reload the page? Form? That will create a GET (query string) or POST entry which would be used. Personally, I’d do that but use a cookie to maintain that (language) state. Back to your method, though. If you’re using a $_GET to tell your PHP script which language (table) to pick from, all you need to do is (as suggested above), add ?l=nl to the Dutch version (OR, if your site defaults to Dutch, use ?l=en for the English version). Of course, if your form is using the POST method, you can do the same thing but use $_REQUEST rather than $_POST (or $_GET).

Regards,

DK

Thanks for your reply… I’m not using mod_negotiation. I was thinking more along the lines of using a redirect like this but no idea if it’s possible:

In other words you’re redirecting to another domain, but still displaying the domain you typed in.

Thanks for the suggestion… that would work to show a language specific URL when you click on the language link. However what happens when you just want to give someone a link to see a particular page in Dutch. I do want to generate a language specific URL but it has to be there for other people to access it too…

Ah I see… that’s that idea out the window then.

The language localization is done by way of database language tables. When you change the site language, this is done in the code by switching to use a different table. Nothing at all is done with the URLs - they always remain the same no matter what language you’re looking at… this is my problem. I need language specific URLs - so a subdomain, top level domain, language parameter, etc.

I think I’ll have to go back to looking at 2 lots of website files (one for each domain), looking up to the same backend database. It doesn’t seem very efficient doing it like this though and I was hoping to be able to just manipulate the URLs instead.

Hi DK,

The user clicks to switch the language from English to Dutch and vice versa. That click re-loads the page, using a different SELECT statement in the PHP code used to display the page. Therefore the URLs remain identical, regardless of which language the page is displayed in. Hope that makes better sense…

ninja,

I get the feeling that we’re not communicating (and I’m searching in the dark for solutions). HOW does your code know to switch to use a different table? I assume that it’s the same script using different tables to generate the same page in different languages so it must know what the acceptable language is from … mod_negotiation (http://httpd.apache.org/docs/2.2/content-negotiation.html)? A PHP value (reading the language sent by the browser to Apache)? If you can fill in that blank, I think we can get going on it.

Otherwise, feeding your advertisement a query string for the nl version may be used by the script to fetch the Dutch version (English assumed … or visa versa).

Regards,

DK

ninja,

I suspect that you’re using mod_negotiation as SitePoint does to separate the language displays. Being language phobic, I don’t have any experience (nor expertise) in this area. In other words, in your place, I’d either learn mod_negotiation quickly (using the code you’ve already got working for you as a template) OR take the easy route and create language specific subdomains for the links you’re after.

I’m up to my @$$ in alligators today but could look into mod_negotiation tomorrow if that would help.

Regards,

DK

ninja,

Sorry, mate, but that’s a security issue which Apache is designed to prevent. You wouldn’t want your website being displayed from someone else’s URL (website), would you? If you change domain, that new domain WILL be displayed.

Back to the language issue, though. If you’re not using mod_negotiation, then you must be using an Apache Environment variable. Have a look at those - then assume assume that your .nl links will be seen by visitors with a browser set for Dutch and .com set for English.

Regards,

DK