views:

30

answers:

1

I have a multiple language website, that uses subdirectories from the root ('/en' for english and '/es' for spanish) for each specific language. Each redirect appends a get variable to the URL, and hides it using a 'P' flag for proxy. My current htaccess file for the spanish subfolder is:

Options +FollowSymlinks
RewriteEngine on
RewriteOptions MaxRedirects=10
RewriteBase /
RewriteRule ^(.*)\.html$ $1.php
RewriteRule ^(.*)$ http://www.domain.com/$1?l=es [P,R=301,L]

The problem is that I also want to append the 'www' to the domain if it was left off. The proxy redirect does not show the 'www.' Is it possible to place a rewriterule before that final one that will append the www, and then still process the final one?

A: 

Is it really necessary, that your www. rewrite is solved via the proxy method? I would recommend a regular 301 redirect if the www. is missing. Many URLs mapping to the same app will just cause session/cookie issuse (read no-www).

Options +FollowSymlinks
RewriteEngine on
RewriteOptions MaxRedirects=10

RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 

RewriteBase /
RewriteRule ^(.*)\.html$ $1.php
RewriteRule ^(.*)$ http://www.domain.com/$1?l=es [P,R=301,L]
Marcel J.