htaccess 使用 get id 重写语言
htaccess rewrite language with get id
您好,我使用 htaccess url 重写和语言检测。
我有域名。com/en/page 翻译成域名。com/page.php?lang=en
它工作得很好,但是如果我将第三个参数添加到 url,我无法得到 lang
ex域.com/en/page/44 44是id
我的 htaccess 规则是:
RewriteRule saints/?([0-9-]+) saint.php?id=
RewriteRule photos-and-videos/?([0-9-]+) category.php?id=
RewriteRule various/?([0-9-]+) article.php?id=
RewriteRule ^([^\.]+)$ .php [NC,L]
RewriteRule ^(en|el)/(.*)$ ?lang= [QSA,L]
要添加额外的参数,您可以使用此规则:
RewriteRule ^(en|el)/(.+)/?(.*)?$ ?lang=&id= [QSA,L]
上面规则中的第三个参数是可选的,所以 /en/page 或 /en/page/foo 都是会工作。
Reordered/fixed 条规则
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ .php [NC,L]
RewriteRule ^(en|el)/(.+)/?(.*)?$ ?lang=&id= [QSA,L]
RewriteRule saints/?([0-9-]+) saint.php?id=
RewriteRule photos-and-videos/?([0-9-]+) category.php?id=
RewriteRule various/?([0-9-]+) article.php?id=
我更改了 3 条规则
RewriteRule saints/?([0-9-]+) saint.php?id=
RewriteRule photos-and-videos/?([0-9-]+) category.php?id=
RewriteRule various/?([0-9-]+) article.php?id=
至
RewriteRule ^(en|el)/saints/?([0-9-]+)$ saint.php?lang=&id= [QSA,L]
RewriteRule ^(en|el)/photos-and-videos/?([0-9-]+)$ category.php?lang=&id= [QSA,L]
RewriteRule ^(en|el)/various/?([0-9-]+)$ article.php?lang=&id= [QSA,L]
效果很好
您好,我使用 htaccess url 重写和语言检测。
我有域名。com/en/page 翻译成域名。com/page.php?lang=en 它工作得很好,但是如果我将第三个参数添加到 url,我无法得到 lang
ex域.com/en/page/44 44是id
我的 htaccess 规则是:
RewriteRule saints/?([0-9-]+) saint.php?id=
RewriteRule photos-and-videos/?([0-9-]+) category.php?id=
RewriteRule various/?([0-9-]+) article.php?id=
RewriteRule ^([^\.]+)$ .php [NC,L]
RewriteRule ^(en|el)/(.*)$ ?lang= [QSA,L]
要添加额外的参数,您可以使用此规则:
RewriteRule ^(en|el)/(.+)/?(.*)?$ ?lang=&id= [QSA,L]
上面规则中的第三个参数是可选的,所以 /en/page 或 /en/page/foo 都是会工作。
Reordered/fixed 条规则
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ .php [NC,L]
RewriteRule ^(en|el)/(.+)/?(.*)?$ ?lang=&id= [QSA,L]
RewriteRule saints/?([0-9-]+) saint.php?id=
RewriteRule photos-and-videos/?([0-9-]+) category.php?id=
RewriteRule various/?([0-9-]+) article.php?id=
我更改了 3 条规则
RewriteRule saints/?([0-9-]+) saint.php?id=
RewriteRule photos-and-videos/?([0-9-]+) category.php?id=
RewriteRule various/?([0-9-]+) article.php?id=
至
RewriteRule ^(en|el)/saints/?([0-9-]+)$ saint.php?lang=&id= [QSA,L]
RewriteRule ^(en|el)/photos-and-videos/?([0-9-]+)$ category.php?lang=&id= [QSA,L]
RewriteRule ^(en|el)/various/?([0-9-]+)$ article.php?lang=&id= [QSA,L]
效果很好