我已经存储在htaccess重写循环?
/public/upload/*
例如用户上传的文件:
/public/upload/gallery/segway/child-on-a-segway.jpg
我目前的.htaccess规则已经消除/public
部分,但我仍然需要摆脱/upload
部分,但是,仅适用于具有给定扩展名但不包含在其他目录中的文件,例如js
或img
。我目前的.htaccess看起来像这样(典型的Zend框架项目):
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
在摆脱/upload
部分工作的希望,我写这在我的.htaccess的末尾:
RewriteCond %{REQUEST_URI} ^(?<!upload|img|js|less|css)/.*(jpg|mp3|png)$
RewriteRule ^(.*)$ /upload/$1
基本上,如果一个文件具有jpg,png或mp3扩展名,并且它的路径不以“upload”,“js”,“css”,“img”或“less”开头,则将前缀“上传”到请求URI 。那么,它失败了。当我在地址栏中输入:http://example.com/gallery/1/php193A.jpg
,我得到一个303错误:
You don't have permission to access /upload//public/upload/public/upload/public/upload/public/upload/public/upload/public/upload/public/upload/public/upload/public/gallery/1/php193A.jpg/1/php193A.jpg/gallery/1/php193A.jpg/1/php193A.jpg/upload/public/gallery/1/php193A.jpg/1/php193A.jpg/gallery/1/php193A.jpg/1/php193A.jpg/upload/public/upload/public/gallery/1/php193A.jpg/1/php193A.jpg/gallery/1/php193A.jpg/1/php193A.jpg/upload/public/gallery/1/php193A.jpg/1/php193A.jpg/gallery/1/php193A.jpg/1/php193A.jpg...
和URL的推移和对几十行,就好像是循环。
这是我第一次处理.htaccess重写规则。我会很感激一些帮助他们设置直线,因为我完全迷失在这里。提前致谢。
我实际上是在错误信息笑了相当困难,ahaha – Cyclone
我的客户不会觉得太好玩了,虽然:( – mingos
这就是为什么我目前正在调试它为你笑 – Cyclone