[英].htaccess: rewrite rules not working as I'd like
Sorry in advance for non technical terms; 对于非技术性条款,请提前抱歉; but keep in mind I really tried a lot to find a solution before posting here.
但是请记住,在此处发布之前,我确实做了很多尝试以找到解决方案。
Under webroot folder i've 2 websites; 在webroot文件夹下,我有2个网站; these are the entry points:
这些是切入点:
/frontend/web/index.php
/backend/web/index.php
My goal is 我的目标是
/frontend/web/index.php
opening http://domain.tld
/frontend/web/index.php
打开http://domain.tld
/backend/web/index.php
opening http://domain.tld/something
/backend/web/index.php
打开http://domain.tld/something
This is my webroot/.htaccess
这是我的
webroot/.htaccess
RewriteCond %{REQUEST_URI} !^something
RewriteRule ^(.*)$ frontend/web/$1 [L]
RewriteRule ^(.*)/something$ backend/web/$1 [L]
In this way, domain.tld/
is opening /frontend/web
(GOOD), but also domain.tld/something
is pointing to frontend/web/index.php
instead of backend/web/index.php
这样一来,
domain.tld/
正在打开/frontend/web
(好),而且还 domain.tld/something
指向frontend/web/index.php
,而不是backend/web/index.php
The leading slash is removed from the URI when used to match rules in an htaccess file. 当用于匹配htaccess文件中的规则时,将从URI中删除前导斜杠。 That means this regex:
这意味着此正则表达式:
^(.*)/something$
will never match a URI that looks like: 永远不会匹配看起来像这样的URI:
something/...
Try changing the regex to: 尝试将正则表达式更改为:
RewriteRule ^something(.*)$ backend/web$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.