hello Gurus I need a help for URL Rewriting of a link product.php?catid=2&subcatid=Garden-Shed-Kits want to make product/Garden-Shed-Kits any body pls help me thanks in regards
try this to edit your .htaccess file use this site: http://www.webconfs.com/url-rewriting-tool.php might work if your host allows you to make changes to .htaccess if it doesn't work...then you might have to do it with php.
Well, URL rewriting is generally done with Apache's mod_rewrite module. There is no way to make product/Garden-Shed-Kits into product.php?catid=2&subcatid=Garden-Shed-Kits, because the 2 is missing. You could translate product/2/Garden-Shed-Kits into that though. Here's an example of a rewrite rule: <IfModule mod_rewrite.c> RewriteEngine On #Don't rewrite if the requested resource is a real file RewriteCond %{REQUEST_FILENAME} !-f #Don't rewrite if the requested resource is a real directory RewriteCond %{REQUEST_FILENAME} !-d #Rewrite only if the request starts with 'product' RewriteCond $1 ^product RewriteRule RewriteRule ^product/([^/]*)/([^/]*)$ product.php?catid=$1&subcatid=$2 [L,QSA] </IfModule> Code (markup): The official reference is at http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html Hope that helps! -- Dan Bernardic
If you still want to exclude the 2 from the "pretty" URL, you could let PHP handle the redirection by looking up which category the subcategory belongs to, assuming there isn't any ambiguity. So, building on dabaR's .htaccess: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^product/ router.php PHP: In router.php you'd then check $_SERVER[ 'REQUEST_URI' ], extract the subcategory, look up which category the product is in, then set $_GET and $_REQUEST accordingly and include product.php. This gives you a lot more flexibility than having everything in the .htaccess file.