动态.htaccess
我正在使用 codeigniter 框架创建模块化 CMS,主要资产目录是:
/public/assets/[admin|public]/[css|images|js]
我当前的 htaccess 路由除请求之外的所有内容将“public”添加到index.php 文件中。
新的模块系统允许每个模块拥有自己的资产,
application/modules/*SOME_MODULE*/assets/[admin|public]/[css|images|js]
我的问题是,是否可以创建一个规则来阻止模块资产目录中的任何内容路由到index.php?
我当前的 .httacces 是:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|public/*)
RewriteRule ^(.*)$ /CI-Playground/index.php/$1 [L]
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]/[css|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]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您的 URL 是模块的各种资产目录的完整路径,您可以轻松地排除它们被重写:
您可能希望删除
application/modules
部分以使您的请求路径更短并且您的目录结构暴露得较少,您可以这样做:不过,我看到您的应用程序目录中有另一个
.htaccess
,您需要检查是否有任何可能阻止外部请求到达的内容模块的文件。Assuming your URLs would be the full path to the modules' various assets directories, you could easily exclude them from being rewritten:
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: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.