[英]301 redirect in htacess for default language
我有帶有qtranslate插件的wordpress網站。 俄語為默認語言(ru)。 我有網頁: http://example.com/en/xxx http://example.com/ru/xxx (302重定向到http://example.com/xxx ) http://example.com/xxx
我需要創建從http://example.com/ru/xxx到http://example.com/xxx的 301重定向
我試圖在htacess中編寫規則以進行重定向,但是出現了重定向循環:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ http://example.com.ua/ [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://example.com.ua/ [R=301,L]
RewriteCond %{HTTP_HOST} ^www.example\.com.ua$ [NC]
RewriteRule ^(.*)$ http://example.com.ua/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !^/ru(/|$)
RewriteRule ^(.*)$ /$1 [R=301]
</IfModule>
# END WordPress
請嘗試以下規則:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ /ru/$1 [NC,L,QSA]
要么
RewriteEngine On
RewriteRule ^ru/(.*)$ /$1 [L,R=301,QSA]
希望它對你有用:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.