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 dom开发者_如何学编程ain 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?
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]
精彩评论