Dynamic .htaccess
I am creating a modular CMS using the codeigniter framework, the main asset directory is:
/public/assets/[admin|public]/[css|images|js]
my current htaccess routes everything except requests starting with 'public' to the index.php file.
The new module system allows each module to have its own assets which would be located at
application/modules/*SOME_MODULE*/assets/[admin|public]/[开发者_如何学Pythoncss|images|js]
my question is, is it possible to create a rule to stop anything from a modules asset directory being routed to index.php?
My Current .httacces is:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|public/*)
RewriteRule ^(.*)$ /CI-Playground/index.php/$1 [L]
Assuming your URLs would be the full path to the modules' various assets directories, you could easily exclude them from being rewritten:
RewriteEngine on
RewriteCond $0 !^(index\.php|images|robots\.txt|public/)
RewriteCond $0 !^application/modules/[^/]+/assets/(admin|public)/(css|images|js)
RewriteRule ^.*$ /CI-Playground/index.php/$1 [L]
You might like to cut out the application/modules
part to make your request path shorter and your directory structure less exposed, which you could do like this:
RewriteEngine on
RewriteCond $0 !^(index\.php|images|robots\.txt|public/)
RewriteCond $0 !^[^/]+/assets/(admin|public)/(css|images|js)
RewriteRule ^.*$ /CI-Playground/index.php/$0 [L]
RewriteRule ^[^/]+/assets/(admin|public)/(css|images|js).*$ application/modules/$0
I see that you have another .htaccess
in your application directory though, which you'll need to check for anything that might prevent outside requests from reaching the modules' files.
精彩评论