A while ago i read a tutorial on how to convert php urls into friendly ones.

index.php?category=23

index.php/category/23

something like the above.

Does anyone have info on this, as i cant find the tutorial no more and not sure on what to search for in what this process is called.

Cheers

    This would be best handled by using mod_rewrite IMO. Just google (or search this forum for) that term (perhaps include 'friendly url' for extra clarity). I'm sure there's are plenty of tutorials on using .htaccess files / mod_rewrite to do stuff like this.

    Off the top of my head (untested), something in your .htaccess file along the lines of perhaps?:

    RewriteEngine on
    RewriteRule ^index\.php\?category=([0-9]+)$ /index.php/category/$1
    

    (Note, I'm not sure if I need to escape that ? or not... I don't do much mod_rewritting to be perfectly honest. And again, this is untested).

    You can also use this guide for mod_rewrite expressions. Also note that you must place your .htaccess file within the appropriate folder in question you wish to apply these rules to.

      hi, thanks for your reply. I've found a few tutorials but still having problems achiving what i need due to the following.

      The following are the combinations i would expect to use

      domainname.com/categoryname/
      domainname.com/categoryname/pagenumber.htm
      domainname.com/pagenumber.htm

      As you can see from the above, i am trying to get to varibles "categoryname" and "pagenumber", however because the first varible can be either depending on which url you use i cant determin one from the other. However the .htm could be used to work out which is which i guess, but this is where things start to get to complex for me.

      Also, my other problem is, because i am collecting 2 varibles sometimes and other times just the 1

      If anyone can help i would be very greatfull, i am very new to MOD REWRITE and to be honest dont have much of a clue to what i am doing.

        My advice, don't post the same problem twice. It's bad forum netiqutte, and risk mods / admins locking threads down.

        I would help out if I knew more about mod_rewrite. Unfortunately, it isn't my forté. I'm sure there are tutorials out there to help out in the event no one here can. Just a matter of continuously searching till you find an explanation that you can work with.

          Write a Reply...