user188962
user188962

Reputation:

Compare http_referer value

My http_referer says this:

   http://www.domain.com/search/?etcetcetcetc...

I need to compare my http_referer to look for this:

   http://www.domain.com/search

And if the first part of the referer is this, then do some code...

Ex:

    if($_SERVER['HTTP_REFERER']=='http://www.domain.com/search'){
          do stuff...

But first I think I need to strip everything after the word "search".

I am not good at regular expressions and this kind of stuff, so help is appreciated... Thanks

Upvotes: 0

Views: 665

Answers (1)

Michael Mrozek
Michael Mrozek

Reputation: 175774

If you just want to check if the string begins with your domain, use strpos:

if(strpos($_SERVER['HTTP_REFERER'], 'http://www.domain.com/search') === 0) {
    // do stuff
}

Upvotes: 5

Related Questions