Forum Moderators: phranque

Message Too Old, No Replies

Help with apache rewrite in httpd.conf (appending query string)

appending query string

         

apache_cts

6:32 am on Mar 2, 2006 (gmt 0)



Hello,

I need to change the following URL

/servlet/Satellite?pagename=OUKPersonal&c=OUKService&cid=1096023562415&t=Service&tab=3

to

/servlet/Satellite?pagename=OUKPersonal&c=OUKService&cid=1096023562415&t=Service&tab=3&mid=1137070318872

using httpd.conf file

If you notice mid=1137070318872 parameter needs to get appened in the end. I used the following rewrite rule, but does not work.

RewriteCond %{QUERY_STRING} ^pagename=OUKPersonal [nc]
RewriteCond %{QUERY_STRING} t=Service [nc]
RewriteCond %{QUERY_STRING} cid=1096023562415 [nc]
RewriteCond %{QUERY_STRING} c=OUKService [nc]
RewriteCond %{QUERY_STRING} tab=3 [nc]
RewriteRule ^/servlet/Satellite(.*)$ /$1&mid=1137070318872 [QSA,R]

The redirected URL in the logs is

"GET /&mid=1137070318872?pagename=OUKPersonal&c=OUKService&cid=1096023562415&t=Service&tab=3 HTTP/1.1" 404

The mid parameter seems to get append to the start of URL. Can anyone help?

jdMorgan

1:50 pm on Mar 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



apache_cts,

Welcome to WebmasterWorld!

Your syntax is a bit off. You must use "?" to tell mod_rewrite that the string following the substitution URL is a queery string:

Internal (silent) rewrite:


RewriteRule ^/servlet/Satellite/?$ /servlet/Satellite/?mid=1137070318872 [QSA,L]

-or-

External redirect (updates browser address bar, changes search engine listing):


RewriteRule ^/servlet/Satellite/?$ http://www.example.com/servlet/Satellite/?mid=1137070318872 [QSA,R=301,L]

Jim