How in php do I get the inbound URL and use its variables? ie www.somesite.com/town.php/looe I want to get Looe and use it to create a redirect to another URL Any help would be great Jamie
what is looe? is it a variable or a value? You can do this: www.somesite.com/town.php?looe=5 and in town.php do this: $looe = $_GET['looe']; and that will give you a variable called $looe which has the valye 5
town1.php?town=looe is the actual URL, so $town=$_GET['town'] and then $town would be the value, ie looe in this example Thanks
depending on your URL logic and if you have any control over the incoming URL you can also use something like $url = $_SERVER['PHP_SELF']; $array = explode("/",$url); $variable = $array['4']; But this method would only work with one type of URL at a time. If this is a link from your own site, Apache's mod_rewrite would offer you the best option and allow you to redirect the browser from the 'server', not from a 'file being stored on the server' using htaccess on shared hosting... RewriteEngine On RewriteRule ^town\.php/([a-zA-Z0-9]*)$ redirected-destination.page?info=$1 where $1 is the part of the URL that changes... you get this from the ([a-zA-Z0-9]*) in the first half of that code.