0

Hi i want to make safe urls for a website. I used php's explode function that way

 $explode = explode("/",$_SERVER['REQUEST_URI']); 

I then was extracting with $explode[2] etc the names inside the url and then with sql statements combined them with the db took ids, names and whatever else. Entered url was like

 http://www.example.com/index.php?var1=value1&var2=value2&var3=value3 

and made it

 http://www.example.com/value1/value2/value3 through .htaccess. 

Code there is

 RewriteRule ^(.*)/(.*)/(.*)$ index.php?var1=$1&var2=$2&var3=$3 [L]

But the site's php is already written fully so i do not want to change all GET queries at url cause now are not working. Is there an easier way to do so or can you correct the code so i can use again GET functions above? I forgot to mention at url value1,value2 etc are not ids (numbers) but the corresponding names. For example if it is for a furniture the url is

 www.example.com/furniture/chair/.. not www.example.com/3/24/...  

Is there any other way to succeed this functionality? Thanks.

  • So I think your real question is - you want the URL to say 'example.com/furniture/chair' but you don't know how to get the numerical ID from 'furniture' and 'chair'. I think the solution is to use a combination of both, for example - 'example.com/3/24/furniture-chair' – andrewtweber Jun 26 '12 at 20:59

1 Answers1

0

I'd say you might also be looking for something like

PHP dynamic DB page rewrite URL

Which will gather any and all variables from a URL and you can use them accordingly from there on in. It would be using htaccess and a similar logic to what your wanting to do, less the rewrite rule the way you have it now.

Community
  • 1
  • 1
chris
  • 36,115
  • 52
  • 143
  • 252