Jump to content

Its being asked before but i cant fined the anwser.


Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.