Jump to content

Simple RewriteRule question...


arianhojat

Recommended Posts

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?

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.