.htaccess 403 after LSWS upgrade

pardis

Well-Known Member
#1
Hello :

after upgrade LS to 4.2.22 website encounter error , after investigate , we found this error related following code :

Code:
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|JPG|JPEG|PNG|BMP|GIF)$ http://www.domain.com [R,NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
what is problem ? why error occured after upgrade ?

Regards
 

pardis

Well-Known Member
#3
-- access which URL trigger 403 error ?
-answer : when open any pic file , error 403 occur . nothing in log .

after comment out above code (all 3) problem resolve
 

wanah

Well-Known Member
#5
The people who manage basic forum support are at a Magento conference at the moment.

From what I understand the first line adds a redirect header allows it to pass to the next line which adds a 403 error.

It does seem correct according to the following Apache documentation that your code shoud show a 403 error.

See here :

http://httpd.apache.org/docs/2.4/en/rewrite/flags.html#flag_r

You will almost always want to use [R] in conjunction with [L] (that is, use [R,L]) because on its own, the [R] flag prepends http://thishost[:thisport] to the URI, but then passes this on to the next rule in the ruleset, which can often result in 'Invalid URI in request' warnings.
Try the following :

Code:
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|JPG|JPEG|PNG|BMP|GIF)$ http://www.domain.com [R,L]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
 

NiteWave

Administrator
#6
I tested with the rules:
Code:
RewriteEngine On

RewriteRule .*\.(jpg|jpeg|gif|png|bmp|JPG|JPEG|PNG|BMP|GIF)$ http://www.domain.com [R,NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
no other rules -- in .htaccess

it works as expected -- a access to .png redirected to www.domain.com, no 403.

you can temporarily remove all other rules and only left above rules, see what's the result: 403 or redirect.
 
Top