hai all,

i want to rewrite url in myproject. the actual url is http://test.com/cat_product.php?cid=2 i want this url change to http://test.com/cat_product.php how do i write .htaccess file.


i tried like this

<FilesMatch "\.(htm|html)$">
SetHandler application/x-httpd-php
</FilesMatch>
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^cat_product-([0-9]+)\.php$ cat_product.php?cid=$1
</IfModule>

but it is not working , please any one have idea help me.

thnks.

Recommended Answers

All 3 Replies

Try this

RewriteEngine on
RewriteRule ^cat_product.php?cid=([0-9]+)$ /cat_product.php

If you will use /$1 you will get the value of cid
please read on net more on it.

RewriteEngine on
RewriteRule ^cat_product.php?cid=(.*?)$ /cat_product.php/$1

thanks for reply,
my .htaccess file here,

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.test.com$
RewriteRule ^$ index.php [L]
RewriteRule ^index index.php [L]
RewriteRule ^aboutus aboutus.php [L]
RewriteRule ^category/(.*) cat_product.php?name=$1 [NC]
RewriteRule ^brands/([a-zA-Z0-9_-]+[^.]+)$ brand_product.php?bname=$1 [NC]
RewriteRule ^carriers/([a-zA-Z0-9_-]+[^.]+)$ categories_name.php?cname=$1 [NC]
RewriteRule ^manufacturers/([a-zA-Z0-9_-]+[^.]+)$ categories_name.php?mname=$1 [L]
RewriteRule ^([^-]*)-([a-zA-Z0-9_-]+[^.]+)$ product_info.php?catname=$1&itemno=$2 [NC]

this is working fine in my localhost but it is not working server(www.test.com). i am geting 404 error ,

why do i get this 404 error . plz help me.

thnks,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.