Apache 我希望能够搜索两个子目录与.htaccess

Apache 我希望能够搜索两个子目录与.htaccess,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我希望能够搜索两个子目录与.htaccess 我有以下目录结构 我的问题是: 例如,当请求 resources/images/players_small_pigs/BMI10.png 正在接收,我希望能够在路径中搜索 webapp/public/resources/images/players_small_pigs/BMI10.png 如果在这里找不到该文件,我想在中继续搜索 webapp/adminpanel/resources/images/players_small_pigs/BMI

我希望能够搜索两个子目录与.htaccess

我有以下目录结构

我的问题是:

例如,当请求

resources/images/players_small_pigs/BMI10.png
正在接收,我希望能够在路径中搜索

webapp/public/resources/images/players_small_pigs/BMI10.png
如果在这里找不到该文件,我想在中继续搜索

webapp/adminpanel/resources/images/players_small_pigs/BMI10.png
有人能帮我使用.htaccess文件让它工作吗?在整个文件夹结构资源、视图和Web服务中,我认为这可能是一个糟糕的结构,也许我应该将它们都放在一个文件夹中,而不是将其拆分为adminpanel和public文件夹,您有什么建议

我在.htaccess中有以下代码:

Options +FollowSymLinks
RewriteEngine on

RewriteRule ^(resources/.*)$ /webapp/public/$1 [L]

RewriteRule ^(resources/.*)$ /webapp/adminpanel/$1 [L]

RewriteRule ^webservices/(.*)$ /webapp/public/webservices/$1 [L]
RewriteRule ^webservices/(.*)$ /webapp/adminpanel/webservices/$1 [L]

RewriteRule ^(public/resources/images/)(sponsors/)?(.*)$ /webapp/$1$2$3 [L]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} adminpanel
RewriteRule (.*) /webapp/adminpanel/views/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !adminpanel
RewriteRule (.*) /webapp/public/views/$1 [L]

RewriteRule ^$ /webapp/public/views/index.php [L]

您可以尝试以下规则:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/resources
RewriteCond %{DOCUMENT_ROOT}/webapp/public%{REQUEST_URI} -f
RewriteRule ^ %{DOCUMENT_ROOT}/webapp/public%{REQUEST_URI} [L]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/resources
RewriteCond %{DOCUMENT_ROOT}/webapp/adminpanel%{REQUEST_URI} -f
RewriteRule ^ %{DOCUMENT_ROOT}/webapp/adminpanel%{REQUEST_URI} [L]

您可以尝试以下规则:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/resources
RewriteCond %{DOCUMENT_ROOT}/webapp/public%{REQUEST_URI} -f
RewriteRule ^ %{DOCUMENT_ROOT}/webapp/public%{REQUEST_URI} [L]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/resources
RewriteCond %{DOCUMENT_ROOT}/webapp/adminpanel%{REQUEST_URI} -f
RewriteRule ^ %{DOCUMENT_ROOT}/webapp/adminpanel%{REQUEST_URI} [L]

为什么需要“搜索”图像,尤其是在这个级别(.htaccess/rewriting)?为什么您的应用程序不知道要显示的图像位于何处?//如果您真的想实现这一点,那么您需要使用
RewriteCond
,只有这样才能检查文件是否存在。为什么您需要“搜索”图像,尤其是在这个级别(.htaccess/rewriting)?为什么您的应用程序不知道要显示的图像位于何处?//如果确实要实现此功能,则需要使用
RewriteCond
,只有这样才能检查文件是否存在。