Regex 我的规则有问题吗?反向引用的行为似乎很奇怪
我正在尝试为我的.htaccess执行重写规则Regex 我的规则有问题吗?反向引用的行为似乎很奇怪,regex,.htaccess,mod-rewrite,Regex,.htaccess,Mod Rewrite,我正在尝试为我的.htaccess执行重写规则 RewriteEngine On RewriteRule ^/LoginUser(.*)$ src/core/index.php?url=$1 [L] 我试图捕获LoginUser之后的所有内容,因此组(.*) 然后用1美元。我只想从查询字符串中排除“/LoginUser” 目前: Input: http://foobar.com/LoginUser/Account/cat Output: http://foobar.com/src/core/i
RewriteEngine On
RewriteRule ^/LoginUser(.*)$ src/core/index.php?url=$1 [L]
我试图捕获LoginUser之后的所有内容,因此组(.*)
然后用1美元。我只想从查询字符串中排除“/LoginUser”
目前:
Input: http://foobar.com/LoginUser/Account/cat
Output: http://foobar.com/src/core/index.php?url=/LoginUser/Account/cat
但我期待着:
Output: http://foobar.com/src/core/index.php?url=/Account/cat
我的正则表达式怎么了?一定是出了什么问题,我的头一直撞在墙上,仍然没有回答。如果有人能给我正确的方向,我将不胜感激
/
,因此您需要的规则是: RewriteRule ^LoginUser/(.*)$ src/core/index.php?url=/$1 [L]
如果您在.htaccess中确实有此项,那么您的模式根本不匹配-在该上下文中,在此时规则测试所针对的URL路径中,前导斜杠总是被去掉。啊。。谢谢问题解决了。。。。谢谢你
Input: http://foobar.com/LoginUserToTest/Account/cat
Output: http://foobar.com/src/core/index.php?url=ToTest/Account/cat
RewriteRule ^LoginUser/(.*)$ src/core/index.php?url=/$1 [L]