/var1/value1/var2/value2 -> var1=value1&var2=value2

Discuss practical ways rearrange URLs using mod_rewrite.

/var1/value1/var2/value2 -> var1=value1&var2=value2

Postby Diederick » Thu Jan 22, 2004 1:58 am

Hi there,

I've searched the forum but I couldn't find a way to do the following:

I'm trying to find out a way to rewrite urls in the form of:

/var1/value1/var2/value2/var3/value3 ..... etc

to

/?var1=value1&var2=value2&var3=value3 .... etc

I'm searching for a way where I can give an unlimited number of variables in te url so: /var1/value1/.../../var100/value100

Can anyone help me?
Thanx
Diederick
 

Postby Guest » Sun Mar 07, 2004 3:38 pm

Guest
 

Postby thinsoldier » Thu Dec 09, 2004 7:30 am

wow thats sad, this is the 2nd highest viewed post on this page and only 1 reply. heh, and this is the same question I've been asking all over the place for days. I've seen others asking this question all over the place also, and never any replies with an answer =(
thinsoldier
 

Postby seomike » Sat Dec 11, 2004 10:14 pm

First you have to use both mod rewrite and a dynamic language.

The dynamic language to create the url string in the <a href="">.

and the mod to match the pattern. Only thing is a mod rewrite is not dynamic. each time you grow your url string you have to write a rewriterule to match. You can't dynamically generate rewrite rules.

The only other possible solution is to use 1 rule

RewriteRule ^(.*)/?$ /somefile.php?vars=$1 [L]

vars would = /var1/value1/var2/value2/var3/value3

then in your somefile.php you just do a

$vars_array = explode("/",$vars);

now you would have an array like this

$vars_array[0] = var1
$vars_array[1] = value1
$vars_array[2] = var2
$vars_array[3] = value2 ....

you could loop through that and grab your variables for the page.

Only thing is a file that is 100 folders deep will never get indexed by a search engine. actually the deepest a search engine will go is about 10 folders deep. So if you all want an invisible web site to the entire world except for you your buddies and by word of mouth I'd think of a better url string :wink:
seomike
 
Posts: 331
Joined: Thu May 06, 2004 7:36 pm
Location: Dallas


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 59 guests

cron