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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.