• 0

Perl RegEx


Question

I sorta need help with this little line

if ($ENV{HTTP_REFERER} =~ <regex here>) {

i need to know the regex to make the equivelent of this * : / / w w w . n o t a r e a l s i t e . c o m *

all my weird strings have failed, i tried everything based on the RegEx tutorials and non e worked, plz help

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

sorry for the addr but if i don't show wehat its used for they might forget to gimme a code with escaped values and i dunno where i might need them all

Link to comment
Share on other sites

  • 0

like if the referer is from somewhere at www.notarealsite.com, then script executes, otherwize it dies. but yeah

Link to comment
Share on other sites

  • 0

i am getting alot of music hotlinking off my site so i am moving the music to a hidden dir and the cgi script is gonna capture the music data and send it though it(song.cgi?songname) but i want it to do if the referer is not from my site, to stop processing, but if it is, to continue and send the music

Link to comment
Share on other sites

  • 0

there's a simpler way. just use Apache's mod_rewrite :) Put this in a .htaccess file in the same directory..

RewriteEngine ON
RewriteCond %{HTTP_REFERER} !^$                                  
RewriteCond %{HTTP_REFERER} !^http://www.notasite.com/.*$ [NC]
RewriteRule .*\.mp3$        -                                    [F]

Just change the site, and the extension to the right one (I'm assuming you're just concerned about mp3s here, and it will block users with a HTTP REFERER from a site not your own. Users without a referrer or with your site will be allowed in :)

The basic regex you want though (assuming you still want to do it your way) shoud be like this:

^http://www.notasite.com/.*

That *should* work just fine...

Link to comment
Share on other sites

  • 0

i got a working regex as

m / : \ / \ / w w w \ . n o t a s i t e \ . c o m \ / /

and now i got a diff problem :p see other post i made

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.