【发布时间】:2020-11-23 19:04:23
【问题描述】:
我的网址是 https://www.myurl.com/subdir/language/login.php。
“语言”参数不是现有的子文件夹。文件夹结构为:
root/subdir/.htaccess
如您所见,.htaccess 文件位于https://www.myurl.com/subdir/.htaccess
我想做一个 .htaccess 重写规则来更改被调用的 uri:https://www.myurl.com/subdir/en/login(不带 .php)
至:https://www.myurl.com/subdir/login.php?lng=en
我目前的方法是:
# MultiViews must be disabled for the rewrite to work
Options -MultiViews
# Turn on the rewriting engine
RewriteEngine On
RewriteBase /subdir/
RewriteRule (en|de)(/login)$ login.php?lng=$1 [L]
但是当我调用 URI https://www.myurl.com/subdir/en/login 时,我得到一个 http 错误代码 404。
【问题讨论】:
-
你的测试成功了,它会抛出一个 500 内部服务器错误。
-
是的,就是这样!还有一个问题,如果情况都一样,但我想在 /subdir/ 前面获得 (en/de) 怎么办?所以网址是myurl.com/en/subdir/login
标签: php regex .htaccess url-rewriting