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; these are the entry points:
在webroot文件夹下我有2个网站;这些是切入点:
/frontend/web/index.php
/backend/web/index.php
My goal is
我的目标是
- Access
/frontend/web/index.php
openinghttp://domain.tld
- Access
/backend/web/index.php
openinghttp://domain.tld/something
访问/frontend/web/index.php打开http://domain.tld
访问/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 /是打开/前端/ web(GOOD),但domain.tld / something指向frontend / web / index.php而不是backend / web / index.php
1 个解决方案
#1
The leading slash is removed from the URI when used to match rules in an htaccess file. That means this regex:
当用于匹配htaccess文件中的规则时,将从URI中删除前导斜杠。这意味着这个正则表达式:
^(.*)/something$
will never match a URI that looks like:
将永远不会匹配看起来像这样的URI:
something/...
Try changing the regex to:
尝试将正则表达式更改为:
RewriteRule ^something(.*)$ backend/web$1 [L]
#1
The leading slash is removed from the URI when used to match rules in an htaccess file. That means this regex:
当用于匹配htaccess文件中的规则时,将从URI中删除前导斜杠。这意味着这个正则表达式:
^(.*)/something$
will never match a URI that looks like:
将永远不会匹配看起来像这样的URI:
something/...
Try changing the regex to:
尝试将正则表达式更改为:
RewriteRule ^something(.*)$ backend/web$1 [L]