views:

48

answers:

2

I have a multiple language website, and I use a php get variable to set the cookie for the language setting. I have multiple subfolders (http://www.site.com/es and http://www.site.com/de) that each have a respective .htaccess file. When accessing these folders, the .htaccess file does this to "silently" redirect the user and add the appropriate php variable:

-------
Options +FollowSymlinks
RewriteEngine on
RewriteOptions MaxRedirects=10
rewriterule ^http://www.site.com/es/$ http://www.site.com/?l=es [P,R=301]
rewriterule ^(.*)$ http://www.site.com/$1?l=es [P,R=301]
-------

When someone accesses the root directory: http://www.site.com, I want to add a ?l=en suffix "silently" to the url. How do I do that? Thanks.

A: 

I don't think it's possible in the method you want.

However, you could (in a round about way) modify your code:

RewritRule ... proxy_add_l.php

In which, the code would:

<?php
$_GET['l'] = $_REQUEST['l'] = 'en';
require 'index.php';
?>

Note this is really, really, bad, and should only be used as a last resort really.

Can't you just redirect them to /en which looks cleaner?

Tim Green
The problem is we already have an established website, and many pages already have a pagerank. If we add the '/en' we would lose those.
Eric Di Bari
Okay. What about just modifying your code to assume the the language if not set?
Tim Green
I'm not quite sure why I didn't think of that suggestion. I just checked to see if 'l' was set as a get variable, and if not set the language variable to english. Thanks Tim.
Eric Di Bari
A: 

I think if you want a fixed value this is perfect possible with something like this:

rewriterule ^http://www.site.com/$ http://www.site.com/?l=en ...

I cant test the result cause am not at home now.

Ronaldo Junior