简体   繁体   English

Mod_rewrite htaccess规则,特定文件无法正常工作

[英]Mod_rewrite htaccess rule with exception for specific files not working

Here is my htaccess file: 这是我的htaccess文件:

Options +FollowSymLinks
RewriteEngine On
AcceptPathInfo On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.domain.com/%2 [L,R=301]

Here is my site structure: 这是我的网站结构:

 error_log
 lib/
 mail/
 public_html/
 www/
 access-logs/
 etc/

The .htaccess file is located inside public_html Inside public_html I have /assets , /images and /uploads : .htaccess文件位于public_htmlpublic_html我有/assets/images/uploads

The rules redirect ok for /assets and /images but for : 规则将/ assets和/ images重定向为ok,但对于:

http://www.domain.com/uploads/100_100/2014/10/24/5/0/841453939422001907988782-1-100_100.jpg

Redirects to www.domain.com. 重定向到www.domain.com。

EDIT: Entry from access_log below: 编辑:从下面的access_log条目:

ip - - [24/Oct/2014:17:54:37 +0300] "GET /uploads/100_100/2014/10/13/d/2/80550090151440232989044-1-100_100.jpg HTTP/1.1" 301 20 "http://www.domain.com/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Ch$

Any ideas why? 有什么想法吗?

Problem seems to be in your redirect rule: 问题似乎出在您的重定向规则中:

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]

Also keep this rule just below RewriteBase line. 还要将此规则保持在RewriteBase行下方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM