任何人都可以帮助进行 .htaccess 优化吗?其实我有下一个代码:
RewriteEngine on
RewriteBase /
DirectoryIndex frontend/www/index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} cpanel/(.*)$
# Why not "-f" - because it's domain of 3d level: VirtualDocumentRoot /path/to/htdocs/%-3/ and if I use "-f" file not founds :(
RewriteCond backend/www/%1 -F
RewriteRule . backend/www/%1 [L]
RewriteCond %{REQUEST_URI} cpanel/(.*)$
RewriteCond backend/www/%1 !-F
RewriteRule . backend/www/index.php?b=%1 [L]
RewriteCond %{REQUEST_URI} !cpanel/(.*)$
RewriteCond frontend/www%{REQUEST_URI} -F
RewriteRule . frontend/www%{REQUEST_URI}
RewriteCond %{REQUEST_URI} !cpanel/(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . frontend/www/index.php?f=%{REQUEST_URI}
文件夹结构:
.
├── .htaccess (with code I provided)
├── frontend
│ ├── www
│ ├── css
│ │ ├── base.css
│ └── index.php
├── backend
├── www
├── css
│ ├── base.css
└── index.php
我需要:
- my.domain.com/base.css显示文件是否存在于根目录或 frontend/www 下
- my.domain.com/dir/base.css显示文件是否存在于 root/dir 目录或 frontend/www/dir 下
- my.domain.com/cpanel/base.css显示文件是否存在于 backend/www 目录中
- my.domain.com/cpanel/dir/base.css显示文件是否存在于 backend/www/dir 目录中
- 如果在任何 nedded 目录中都找不到文件,我会从 frontend/www/index.php 或 backend/www/index.php 显示 index.php(如果 URI 以 cpanel/... 开头)。
看起来我的 .htaccess 工作得很好,但我不确定它的质量。