Apache 我可以使用mod_rewrite重定向到不同的URL吗?

Apache 我可以使用mod_rewrite重定向到不同的URL吗?,apache,mod-rewrite,Apache,Mod Rewrite,当我进入http://www.example.com/index.php到鼓风机 我可以使用rewriteRule重定向到http://www.example.com/web/index.php 好的,现在如果我输入http://www.example.com/test.php 但是web/文件夹中不存在“test.php”文件 实际上,此文件存在于/admin文件夹中 那么,我可以重定向到http://www.example.com/admin/test.php? 使用http://www

当我进入http://www.example.com/index.php到鼓风机
我可以使用rewriteRule重定向到http://www.example.com/web/index.php

好的,现在如果我输入http://www.example.com/test.php
但是web/文件夹中不存在“test.php”文件
实际上,此文件存在于/admin文件夹中
那么,我可以重定向到http://www.example.com/admin/test.php

使用http://www.example.com/xxx.php重定向到不同的URL?
以下是我的.htaccess,但它无法工作…

重新启动发动机

重写规则^(.*)$web/$1[NC]

重写规则^(.*)$admin/$1[NC]

尝试使用以下方法:

RewriteEngine On

# checks if requested file exists in /web/
RewriteCond %{DOCUMENT_ROOT}/web%{REQUEST_URI} -f
RewriteRule ^(.*)$ /web/$1 [L]

# checks if requested file exists in /admin/
RewriteCond %{DOCUMENT_ROOT}/admin%{REQUEST_URI} -f
RewriteRule ^(.*)$ /admin/$1 [L]