0
我有一个.htaccess
文件应该将所有请求重定向到index.php?url=$1
,除非请求指向图像或特定文件。如果这些文件夹位于public/
文件夹的某个位置,则应将其送达。如果请求的文件是public/
文件夹以外的图像,则将其重定向到默认图像,并且如果请求的文件是HTML,JS,CSS,SWF文件并且不在public/
文件夹中,则应发送一个类似404-not found
的文件背部。 一切正常,除非我要求/public
的图片或让我们说public/images
它们也被重定向到默认图片。我已经尝试了一切,即使是%{ENV:REDIRECT_STATUS}
,但仍然一样。任何想法我怎么能让循环停止如果文件已在第11行服务?重写循环不会停止
下面是.htaccess文件:
<IfModule mod_rewrite.c>
RewriteEngine on
SetEnv HTTP_MOD_REWRITE on
RewriteBase /wsproject/
Options All -Indexes
DirectoryIndex index.php
RewriteCond %{REQUEST_URI} ^public/.*\.(html|css|js|swf|jpe?g|png|gif|bmp|ico)$ [NC]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule^- [L]
RewriteCond %{REQUEST_URI} \.(jpe?g|png|gif|bmp|ico)$ [NC]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule^public/errors/img-not-found.png [L]
RewriteCond %{REQUEST_URI} \.(html|css|js|swf)$ [NC]
RewriteRule^- [R=404,L]
RewriteCond %{REQUEST_URI} !^public/.*$ [NC]
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>
我使用的代码从原来的答案,你可以在这里看到:Apache Rewrite module, complex rules