How to pass http://www.domainname.com 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: http://wwww.mysite.com/link-10-www.domain.com/click.htm?id=497&mid=13&prod=1&productname=name&target=http://www.domainname.com/name2.htm. 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.

comments:

Thanks i made correction above :)

Other Answer2

Your example will look at this query string:

link-10-www.domain.com/click.htm

and assign

$1 = 10
$2 = www.domain.com/click

and rewrite to

link.php?id=10&link=www.domain.com/click

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 (wwww.mysite.com).

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 "www.domain.com/click" and that file doesn't exist?

Hard to tell without knowing more.