WordPress and .htaccess
I have a website powered by WordPress MU. The front page of the site is translated in several languages. How do I rewrite the following URLs?
http://www.example.com/?lang=en
http://www.example.com/?lang=fr
to:
http://www.example.com/en/
http://www.example.com/fr/
This is my current .htaccess
,
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - 开发者_开发知识库[L]
# Uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]
# END WordPress
I have not tested so I am not 100 % sure if it works but that should give you some ideas.
I advice you to take a look at the documentation of mod-rewrite.
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
#languages
RewriteRule ^/(en|fr)/(.*)$ /$2?lang=$1
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]
# END WordPress
This will redirect and preserve the original query string:
RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^([a-z]{2}) /?lang=$1&%1 [L]
RewriteRule ^([a-z]{2}) /?lang=$1 [L]
RewriteEngine On
RewriteBase /
RewriteRule ^en /?lang=en
RewriteRule ^fr /?lang=fr
精彩评论