Hello,

I need some help in url rewrite i tried alot but not able to get this done.

Have a look at url

http://www.mydomain.com/insurance/metatags.php?cat_id=44


I need to rewrite to make html file

Below is the code I m using but no success

Options +FollowSymLinks
RewriteEngine on
RewriteRule metatags-cat_id-(.*)\.htm$ metatags.php?cat_id=$1


Also DO i need add / write some code in php file also to make this work ?

One guy said have u just added .htaccess

I relied: yes

he said then this will not work

SO Can any one help me out with this.

Thanks
DSS

Working with mod_rewrite can be tricky, especially if you are working with subdirectories.

Do your hyperlinks use this format? /insurance/metatags-cat_id-44.htm

try this

RewriteRule ^insurance/metatags-cat_id-(.*)\.htm$ insurance/metatags.php?cat_id=$1

it might also work this way:

RewriteRule ^metatags-cat_id-(.*)\.htm$ metatags.php?cat_id=$1


A couple of things you need to know about the .htaccess file.

1. It does not work on a Microsoft server.

2. It will not work with all hosting companies. Some hosting companies disable server overrides.

The best idea is not to use .*

RewriteRule ^insurance/metatags-cat_id-([0-9]+)\.htm$ insurance/metatags.php?cat_id=$1

I agree with php_deamon. If you are expecting numbers only, then his method limits the rewrite rule to numbers.

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.