Invalid User
Invalid User

Reputation: 21

Mod Rewrite variable contains a url with special characters

I recently discovered mod rewrite and I was wondering if it's possible to rewrite a variable which contains an outbound url.

So far it is not working at all. I assume it is caused because of the special characters in the variable and I have no clue how I can solve this.

My .htaccess code so far:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^url/(\w+)/?$ link.php?url=$1 [L]

I would like to rewrite:

http://www.example-site.com/url/http://www.affiliate-site.com/dir/index.php?page=home

To:

http://www.example-site.com/link.php?url=http://www.affiliate-site.com/dir/index.php?page=home

Any help would be much appreciated.

Thanks in advance.

Upvotes: 2

Views: 1391

Answers (1)

Kerry Jones
Kerry Jones

Reputation: 21858

\w is only a-z, A-Z and 0-9

This should do the trick:

RewriteRule ^url/(.+)/?$ /link.php?url=$1 [L]

This cheat sheet can help:
http://regexlib.com/CheatSheet.aspx

Upvotes: 1

Related Questions