> you will need to use RewriteCond to Match/Extract a
Query String
# Redirect old frame-based URL requests to URL-path given in query string
# accept optional parm(s) before the "url=" name/value, but none after
RewriteCond %{QUERY_STRING} ^(([^&]*(&[^&]*)*)&)?url=http://(www\.)?domain\.com([^&]*)$ [OR]
# require parm(s) before and accepts optional parm(s) after the "url=" name/value
RewriteCond %{QUERY_STRING} ^(([^&]*(&[^&]*)*)&)url=http://(www\.)?domain\.com([^&]*)((&[^&]*)*)$
RewriteRule ^$ http://domain.com/%5?%2%6 [R=301,L]
This code can correctly retain additional query parameters preceding and/or following the "url=" name/value pair. It will also accept either "domain.com" or "www.domain.com" in the originally-requested query string.
That is, the rule will redirect
domain.com/?url=domain.com/<any-URL-path> to domain.com/<any-URL-path>/, or
domain.com/?<any-name1>=<any-value1>&url=domain.com/<any-URL-path> to domain.com/<any-URL-path>/?<any-name1>=<any-value1>, or
domain.com/?url=domain.com/<any-URL-path>&<any-name2>=<any-value2> to domain.com/<any-URL-path>/?<any-name2>=<any-value2>, or
domain.com/?<any-name1>=<any-value1>&url=domain.com/<any-URL-path>&<any-name2>=<any-value2> to domain.com/<any-URL-path>/?<any-name1>=<any-value1>&<any-name2>=<any-value2>
with "<any-name1>=<any-value1>" and "<any-name2>=<any-value2>" each representing one or more additional name/value pairs and either "domain.com" or "www.domain.com" specified in the requested query string.
Essentially, the "url=domain.com/<any-URL-path>" is "cleanly" removed from the query string, and the rest of the query string (if any) is retained.
See the resources cited in our Apache Forum Charter and the example threads and tutorials in our Apache Forum Library for more information. Links to both of these are at the top of this page.
The code snippet above assumes that you already have other working RewriteRules in your .htaccess file, and so have already enabled mod_rewrite.
Jim