MOD REWRITE(htaccess)如何重写:index.php?lang = $ 1&pagePL = $ 2

时间:2019-06-18 17:30:02

标签: regex .htaccess mod-rewrite

如何重写:

index.php?lang=$1&pagePL=$2

这样我只有mydomain.com/(value of pagePL)

这是我的权限,但是不起作用...

RewriteRule ^(\w+)$ index.php?lang=$1&pagePL=$2 [L]

这是我的htaccess文件:

    AddHandler application/x-httpd-php70 php
    Options FollowSymLinks
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^/?$ index.php?lang=pl [L]
    RewriteRule ^en/?$ index.php?lang=en [L]
    RewriteRule ^(\w+)/(\w+)$ index.php?lang=$1&pageEN=$2 [L]
    RewriteRule ^(\w+)$ index.php?lang=$1&pagePL=$2 [L]

它适用于该网站的英文版:

http://nabalkany.hekko24.pl/en/menu

但不适用于:

http://nabalkany.hekko24.pl/menu

1 个答案:

答案 0 :(得分:1)

您只有1个捕获组,因此应将lang=$1&从重定向路径中删除,并将$2变成$1

RewriteRule ^(\w+)$ index.php?pagePL=$1 [L]