First off, I don't know if this is the right place to ask, so if there is a better way to solve my problem I'll refrase my question in the appropriate section. Problem: I have a directory from the free php directory script that is rather simple (and free). The categories show like this: "http://hotgossip.be/index.php?c=481" whereas I would like them to show something like "http://hotgossip.be/Youth" (the category in question by example). Can this be taken care of in php? Does anybody have a free php directory script that is already changed in this manner?
Hi you don't have to change the script you could simply use mod_rewrite example RewriteRule ^index-(.*).htm$ index.htm?cat=$1 [QSA,L] rewrites index.htm?cat=412 to index-412.htm If you want names I agree it may be better to change script that uses category names which you can than rewrite Expat
Yeah, I thought of that, and of course only get pretty category numbers, not text. Changing the script is another good idea, but I tried installing three of the most popular free scripts before this one, and they all gave me so much trouble with making categories that I gave up on them. I am thinking that Wordpress uses a php re-writing code, but I don't know for sure how it works. Would love to see something like the wordpress url rewrite (and a few other plug-ins) in action on this script
It's not too bad, I use this in my .htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] Code (markup): Basically if the file or folder they're looking for doesn't exist it redirects it to index.php. So if someone went to http://youdomain.tld/Youth you could $_SERVER[REQUEST_URI] in your index.php file to see what they were looking for. <?php //Say $_SERVER['REQUEST_URI'] = '/Youth/Clubs'; $category = split('/', $_SERVER['REQUEST_URI']); $category_path = $category[1]; //this is Youth $company_name = $category[2]; //this is Clubs ?> Code (markup): I would assume you have categories table setup and you could take that pathname and lookup the category name to get the category ID and then go from there. Just make sure to use mysql_escape_string on your categories and make a nice error page if you can't find what they're looking for. -the mole
You do need to change the script to make it use the rewritten URLs (it's not much good having a category acessible at a url if all visible links being found by search engines still use the .php url), and to do it automatically for any category name you'll need to replace spaces with hypens, strip accents if applicable, and have a fallback mechanism (such as using id numbers) for when the category name contains special characters. Hence the value of having a script that handles all that for you... the .htaccess is the easy part.