I'm working on a webpage that takes a URL as a parameter, and would like it to be easily indexed by search engines. One requirement is that each URL appears as a directory.
My script is in the format:
myscript?url=<a url>&page=1
I'd like redirects to look something like:
lookup/<a url>/page:1/
The URL is predictably giving me trouble... I just want to tell mod_rewrite to select anything after "lookup/" and before "/page:". Of course, nothing is ever as simple as it could be.
Here's the rewrite as it is now:
RewriteEngine on
RewriteRule ^/lookup/(.+)/page:([0-9]+)(/?)$ /myscript?url=$1&page=$2 [L]
This works great, except it fails when URLs are properly encoded. Take the example of "www.google.com/finance". Here's what happens when I enter these URLs into my browser's address bar:
#this works
lookup/www.google.com/finance/page:1/
#this doesn't work. url is cut off before the ?
lookup/www.google.com/finance?foo=bar/page:1/
#doesn't match rewrite at all!
lookup/www.google.com%2Ffinance/page:1/
I'm at a loss as to how to do this... Shouldn't (.+) select anything? Do I need to tell mod_rewrite to ignore query parameters somehow?
Thanks