动态.htaccess

发布于 2024-09-16 02:01:20 字数 533 浏览 3 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

¢蛋碎的人ぎ生 2024-09-23 02:01:20

假设您的 URL 是模块的各种资产目录的完整路径,您可以轻松地排除它们被重写:

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]

您可能希望删除 application/modules 部分以使您的请求路径更短并且您的目录结构暴露得较少,您可以这样做:

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

不过,我看到您的应用程序目录中有另一个 .htaccess ,您需要检查是否有任何可能阻止外部请求到达的内容模块的文件。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文