Last active
August 29, 2015 13:56
-
-
Save maaaks/8818231 to your computer and use it in GitHub Desktop.
A simple (?) multilanguage site configuration for
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When opened on *.ru domain, show /content/ru/pagename.php | |
# When opened on other domain, show /content/en/pagename.php | |
Options -Indexes +FollowSymlinks | |
RewriteEngine On | |
RewriteBase / | |
# Prevent from multiple runs of this file | |
RewriteCond %{ENV:REDIRECT_WASHERE} !^$ | |
RewriteRule ^ - [L] | |
RewriteCond %{ENV:WASHERE} !^$ | |
RewriteRule ^ - [L] | |
RewriteRule ^ - [E=WASHERE:YES] | |
# Remove www prefix | |
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] | |
RewriteRule ^(.*)$ http://%1/$1 [L,R=301] | |
####### | |
# Here is the place for special magic | |
RewriteRule ^index/?$ / [L,R=301] | |
####### | |
# When accessing static files, return them directly | |
RewriteRule ^s/(.+)$ s/$1 [L] | |
# All other URLs should have trailing slashes | |
RewriteRule ^(.*[^/])$ $1/ [L,R=301] | |
# Choose language depending on domain | |
RewriteCond %{HTTP_HOST} \.ru$ | |
RewriteRule ^ - [E=LANGUAGE:ru] | |
RewriteCond %{ENV:LANGUAGE} ^$ | |
RewriteRule ^ - [E=LANGUAGE:en] | |
# Empty means «index.php», trailing slash means «.php» | |
RewriteRule ^$ index.php | |
RewriteRule ^(.*)/$ $1.php | |
# Convert page name to file name | |
RewriteRule ^(.*[^/])/?$ content/%{ENV:LANGUAGE}/$1 [L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment