arianhojat Posted September 11, 2007 Share Posted September 11, 2007 I am just starting to get back into Mod_Rewrite, I forget the logic behind some stuff, for example lets say we want to stop leechers from taking images. The chained RewriteCond/RewriteRules written in logic as it seems most understand to me: if(no http referer OR http referer coming from another site) AND if( requesting gif/jpeg/jpg/png) then (serve another picture to them (or can set Forbidden so shows up as an X on their site )) But in mod-rewrite language its more like this: RewriteCond if(no http referer) OR RewriteCond if(http referer coming from another site) RewriteRule THEN if( requesting gif/jpeg/jpg/png) Serve another picture (or can set Forbidden) Not sure of the url pattern parameter used in the RewriteRule, could that part be set in the conditions?, so 'if' they are requesting an image seems like a condition to me, but alas mod_rewrite prob doesnt work this way with its trickxies. I guess I am just confused as what the url pattern does in the rewrite part, if its a 'filter' then shouldnt it go in the conditions? Quote Link to comment https://forums.phpfreaks.com/topic/68837-simple-rewriterule-question/ Share on other sites More sharing options...
hackerkts Posted September 11, 2007 Share Posted September 11, 2007 RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?howtoinstallscript.com(/)?.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?sky-w0rld.blogspot.com(/)?.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://72.14.253.104(/)?.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://66.218.69.11(/)?.*$ [NC] RewriteRule .*\.(gif|jpg|jpeg|bmp)$ http://howtoinstallscript.com/images/nohotlinking.jpe [R,NC] just got to modify it, actually if you google it you should be able to find the codes.. Quote Link to comment https://forums.phpfreaks.com/topic/68837-simple-rewriterule-question/#findComment-346082 Share on other sites More sharing options...
arianhojat Posted September 11, 2007 Author Share Posted September 11, 2007 sorry maybe misunderstood myquestion. I already know how the rule supposed to look like. My question was more of a why does mod_rewrite have an 'if' part not in a condition but in the 'action' part of a rule. Like how would you describe in human thinking what mod_rewrite is doing? In human logic, you would think this is the case... (no http referer) OR (http referer coming from another site) AND (requesting gif/jpeg/jpg/png) THEN serve another picture to them but instead its seems: (no http referer) OR (http referer coming from another site) THEN check to see if (requesting gif/jpeg/jpg/png) and if thats the case then serve another picture to them thanks if can update. Quote Link to comment https://forums.phpfreaks.com/topic/68837-simple-rewriterule-question/#findComment-346116 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.