How to pass as variable in htaccess?

Tag: .htaccess Author: lhl00077 Date: 2009-08-01

In my htaccess I have line

RewriteRule ^link-([0-9]+)-(.*).htm$ link.php?id=$1&link=$2 [L,NC]

For variable 2 there may be link as well. For example: When i click on this link, page not found message is displayed. Can anyone help me to find the solution?

Thanks for your co-operation

Other Answer1

Your RewriteRule and your example appear to be completely different. Your RewriteRule shows a redirect matching a URL with link-123-something.htm in it, but the example URL you give goes to click.htm.

If you want click.htm to redirect somewhere, you'll need a separate RewriteRule.


Thanks i made correction above :)

Other Answer2

Your example will look at this query string:

and assign

$1 = 10
$2 =

and rewrite to


If that is not happening, I would check whether you have a file called link.php. Also, you have four w's in your example (

If you have a file called link.php, can you tell whether it gets called? Since it is being passed a link, perhaps it is redirecting to "" and that file doesn't exist?

Hard to tell without knowing more.