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

Have a look at url


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.


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.