繁体   English   中英

301在Htacess中重定向为默认语言

[英]301 redirect in htacess for default language

我有带有qtranslate插件的wordpress网站。 俄语为默认语言(ru)。 我有网页: http://example.com/en/xxx http://example.com/ru/xxx (302重定向到http://example.com/xxxhttp://example.com/xxx

我需要创建从http://example.com/ru/xxxhttp://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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM