paulman888888 Posted May 24, 2009 Share Posted May 24, 2009 hi; I found sometime back someone asking how to get htaccess to split up fake folders into real variables and values; ill explain, something like site.com/variablename1-variablevalue1/variablename2-variable value2/ went to this site.com/?variablename1=vabariablevalue1&variablename2=variablename2 basicly the variables name and value were seperated by '-' How would i go about making a loop which puts all variable names and values into a understandable form for PHP? Am not good with htacces but good with PHP. Thankyou Paul Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted May 24, 2009 Share Posted May 24, 2009 You shouldn't have to do anything. Just use $_GET as normal. Eg: $_GET['variablename1'] and $_GET['variablename2'] Quote Link to comment Share on other sites More sharing options...
paulman888888 Posted May 24, 2009 Author Share Posted May 24, 2009 No i mean i want .htaccess to make my URLs pretty Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted May 24, 2009 Share Posted May 24, 2009 To do this you'd use mod_rewrite. So if you url is site.com/foo-123/bar-abcd Then this is what will be in your .htaccess RewriteEngine On RewriteRule foo-([0-9]+)/bar-([a-z]+)/ page.php?foo=$1&bar=$2 Now in page.php you'd use $_GET['foo'] for the first value, $_GET['bar'] for the second value. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.