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 Link to comment https://forums.phpfreaks.com/topic/159487-its-being-asked-before-but-i-cant-fined-the-anwser/ 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'] Link to comment https://forums.phpfreaks.com/topic/159487-its-being-asked-before-but-i-cant-fined-the-anwser/#findComment-841304 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 Link to comment https://forums.phpfreaks.com/topic/159487-its-being-asked-before-but-i-cant-fined-the-anwser/#findComment-841309 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. Link to comment https://forums.phpfreaks.com/topic/159487-its-being-asked-before-but-i-cant-fined-the-anwser/#findComment-841317 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.