Reputation: 13
I need to create a series of redirects for personalized urls. They need to go from a directory on my server to a more complex url on another which includes a query string based on the original url. Here is an example:
I would like to rewrite from this: http://www.mywebsite.com/TestDirectory/John.Doe
to this:
http://their.server.com/adifferentdirectoryname/page.aspx?u=John.Doe&s=lorem&dm=purl
There will be hundreds of these personalized urls I will send out, so I need the solution to account for that so that I don't have to write this for hundreds of names.
Any help is greatly appreciated. Much Thanks!
Upvotes: 1
Views: 75
Reputation: 108246
I think you want something like this:
RewriteRule ^TestDirectory/(\w+\.\w+)$ foo.aspx?u=$1 [R]
The regex \w+\.\w+
matches a word, a dot, and another word. The $1
is replaced with the captured string from the regex. The [R]
means to actually redirect the user.
These rules are tough to get just right so I recommend reading through some examples.
Upvotes: 2