如果现有文件/文件夹存在于特定目录中,则重定向到现有文件/文件夹或转到index.php
我有一个文件夹 App\ressources
,其中包含网站的所有图像、javascript 库。
我想做的是重定向到现有的 image/js 或转到将处理请求并获取当前模块/控制器/操作的 index.php 文件。
所以我做了这个:
RewriteEngine On
RewriteCond App/ressources/$1 -d [OR]
RewriteCond App/ressources/$1 -f
RewriteRule ^(.+)$ App/ressources/$1 [L]
RewriteRule ^(.*)$ index.php [QSA]
这应该不难,但“调试”是不可能的。
I have a folder App\ressources
that contains all the images, javascript library of the website.
What i'm trying to do is to redirect to the existing image/js or go to the index.php file that will handle the request and get the current module/controller/action.
So i made this :
RewriteEngine On
RewriteCond App/ressources/$1 -d [OR]
RewriteCond App/ressources/$1 -f
RewriteRule ^(.+)$ App/ressources/$1 [L]
RewriteRule ^(.*)$ index.php [QSA]
It shoud not be difficult but "debuging" is not possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我问了同样的问题,但我没有得到答案。
这是我的解决方法:
基本上我们将所有内容(不作为文件存在的内容)重定向到 App/ressources,如果它仍然不存在,我们将其重定向回 / root 目录。然后我们将其重定向到index.php。
I've asked for same question but i didn't get an answer.
Here is my workaround:
Basically we redirect everything (what doesn't exists as file) to App/ressources and if it still doesn't exist we redirect it back to / root dir. Then we redirect it to index.php.