Hi, I'm very confused about the use of mod_rewrite. I have a site with categories: www.sitename.com/category.php?id=1&name=cat-name Now I would like to have this displayed as www.sitename.com/cat-name/ Firstly, how do I do this Secondly do I need to change my link urls generated in my php script to /cat-name Help would be mucho appreciated Mark
Hi Mark When you are starting out it's quite good to have something helpful in your new url so it doesn't get confused with other urls on the site. so instead of www.sitename.com/cat-name/ try www.sitename.com/keyword/id/cat-name/ and then in your .htaccess file you can have <IfModule mod_rewrite.c>[/color] [color=black]RewriteEngine On[/color] [color=black]RewriteBase /[/color] [color=black]RewriteRule ^keyword/(.*)/(.*)$ /category.php?id=$1&name=$2[/color] [color=black]</IfModule> Code (markup): The keyword can be changed to time or files or whatever you want stuffed in there. Using the ID too can be useful because sometimes names get duplicated. As for generating the new urls, you just need to find all the places in your code where you write a link and update the code. It can be timeconsuming depending on the software you are working with. Sarah
Thanks Sarah. I read something last nite that cleared my head up about mod_rewrite. Turns out I was all messed up in my head about how it worked. I always thought it was a way of turning http://www.foo.com/something.php?name=James into http://www.foo.com/something/james.htm but it is in fact entirely the other way round. Silly me.
Happy to help. Have downloaded your timesheet software and looking forward to taking a look at that too - so we've helped each other
Hi Sarah, Cool, let me know if I can help you with anything in it. If you decide to buy just let me know before hand and I'll offer you a healthy discount