Hello lads, my .htaccess file is giving me a headache and I need your help to fix it (no, an aspirin won't do ). I'm working on a multilingual website on an Apache 1.3.34 server and I would like all visitors to be sent to the English homepage /en/index.htm, including the following: A permanent redirect from the non-www version to the www-version of the domain; A permanent redirect from the root directory to /en/index.htm A rule so that /en/index.htm appears as /en/ After fiddling around for a while I managed to get the first 301 redirect working (see the code below), but not the other two. Can anyone help me out, please? Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^mydomain.tld [NC] RewriteRule ^(.*)$ http://www.mydomain.tld/$1 [R=301,NC,L] Code (markup):
After a long internet search and a few hours of more fiddling with my .htaccess I was able to find the correct pieces of coding that I need thanks to DP-member Stephen D. Sandecki (a.k.a. ssandecki) and his great practical .htaccess redirect examples. I solved the second and third issues by adding the following piece of coding to my .htaccess file: RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*[COLOR="Green"]index.htm[/COLOR]\ HTTP/ RewriteRule ^[COLOR="Green"]index.htm[/COLOR] en/$1 [R=301,NC,L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*[COLOR="Green"]index.htm[/COLOR]\ HTTP/ RewriteRule ^en/[COLOR="Green"]index.htm[/COLOR] en/$1 [R=301,NC,L] Code (markup): The first two lines permanently redirect every request of the index.htm file in the root directory to the English base directory en/, while the second two lines permanently redirect every request of the index.htm file in the English folder to the English base directory en/. While I was on it, I discovered that these lines of coding also work to permanently redirect wrong incoming requests of the non-existent index.html files to the base directories in their respective folder. For instance: RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*[COLOR="Red"]index.html[/COLOR]\ HTTP/ RewriteRule ^en/[COLOR="Red"]index.html[/COLOR] en/$1 [R=301,NC,L] Code (markup): And the headache has gone...