如何使用参数更正重定向 URL 并更改语言



我在使用 htacces 文件正确重定向时遇到问题。我的网站有3种语言PL,EN和RU。主要语言是PL,它适用于例如 https://mypage.domain.pl/,如果我像这样添加参数语言 https://mypage.domain.pl/?language=en 然后加载英文版本。

我需要这样的东西,如果我放 https://en.mypage.domain.pl/然后加载英文版本,如果我输入 https://mypage.domain.pl/?language=en 然后重定向到 https://en.mypage.domain.pl/并加载英文版本。

我已经在服务器上激活了通配符。

这是最新版本,我尝试手动重定向

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Redirect 301 https://ru.dev.dobrestronyinternetowe.pl/ /?language=ru

</IfModule>
# END WordPress
# BEGIN LiteSpeed
<IfModule Litespeed>
SetEnv noabort 1
</IfModule>
# END LiteSpeed

编辑 2

我做了一些东西,但它在 50% 中工作,只将子域转换为参数

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^([^.]+).dev.dobrestronyinternetowe.pl$ [NC]
RewriteRule ^ http://dev.dobrestronyinternetowe.pl/?language=%1 [L,R]
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN LiteSpeed
<IfModule Litespeed>
SetEnv noabort 1
</IfModule>
# END LiteSpeed

最新更新