How to match URL?

$homepage = "http://www.example.com/";
$currentpage = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];

For some reason can make this work please help!

if(preg_match('/'.$homepage.'[?]language_id=[0-9]/', $currentpage))

P.S. String to match is this:

http://www.example.com/?language_id=7

Why not reference $_GET[‘language_id’]?

can you please explain the question please, what is url matching

I simply want to check if the current URL matches the one I specify and if so redirect to home page!

Sorry my PHP is bad. Could you please shed some light please?

Buddy you are a awesome!!!

Nailed it with this:

$homepagelanguage = ''.$homepage.'?language_id='.$_GET['language_id'].'';

By the way, there’s a better way to do this than have the user select a language. $_SERVER[‘HTTP_ACCEPT_LANGUAGE’], which contains a comma delimited list of languages the user prefers. On my browser this is “en-US,en;q=0.8”, ‘en-US’ being the code for US English, ‘en’ for generic English and I have no idea what the last one is. The browser fetches this setting from the OS by default though the user can specify their choice.

Some rather heavy reading, but “q” is the “quality value” or “quality factor”

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.