Regex 在某些情况下修改

Regex 在某些情况下修改,regex,apache,.htaccess,mod-rewrite,url-rewriting,Regex,Apache,.htaccess,Mod Rewrite,Url Rewriting,我的网站有以下结构 /index.php /anotherpage.php /login/ /view/ 我在/view/目录中设置了mod rewrite,以便可以从/view/aBc123访问/view/?id=aBc123 但我试图实现的是一种能够在不干扰站点其余部分的情况下从该URL中删除/view/的方法 所以URL看起来像 domain.com/aBc123 但这样做不会影响以下内容: domain.com/index.php domain.com/anotherpage.ph

我的网站有以下结构

/index.php
/anotherpage.php
/login/
/view/
我在/view/目录中设置了mod rewrite,以便可以从/view/aBc123访问/view/?id=aBc123

但我试图实现的是一种能够在不干扰站点其余部分的情况下从该URL中删除/view/的方法

所以URL看起来像

domain.com/aBc123 
但这样做不会影响以下内容:

domain.com/index.php
domain.com/anotherpage.php
domain.com/login
domain.com/view
请注意,在实际的站点上有更多的合法目录和文件,只是将它们作为我希望继续工作的场景示例显示

因此,当它不是一个.php文件并且不是一个合法的目录时,场景是将它作为一个ID来处理


我正在尝试确定此场景的mod rewrite是什么

您可以在
文档中使用此代码。\u ROOT/.htaccess
文件:

RewriteEngine On
RewriteBase /

# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?!view/).*) view/$1 [L,NC]