I am having trouble with a redirect abd I've setup the following rule. I would really appreciate some help! Without the query string of serial=100 the redirect works,
THE_REQUEST is the literal HTTP request sent by the browser.
GET /somepath/somefile.ext?someparam=somevalue HTTP/1.1
Your pattern makes no provision for there to be any parameters contained in that request.
vince786
1:53 am on Feb 11, 2011 (gmt 0)
Thanks g1smd. I am quite confused now. So is it correct that I need to rewrite my rule as folows: RewriteEngine On RewriteCond %{REQUEST_URI} ^.*/shopping/index\.jsp\ HTTP/ [NC] RewriteCond %{SERVER_PORT} ^8080$ RewriteCond %{QUERY_STRING} ^serial=100$ RewriteRule ^.*index\.jsp$ newhost:10080/shopping/index.jsp?serial=100 [R=301,L]
An existing rule that works is without the query string. So my task is to add a new rule that includes the query string. Based on what you said it looks like the first RewriteCond is not required. So I tried the fol:
Basically I have a url that needs to be rewritten which includes a new server name and port. :
htp://oldHost:8080/shop/index.jsp?name=abc to htp://newHost:10080/shop/index.jsp?name=abc
So I added the fol rule:
RewriteCond %{REQUEST_URI} ^.*/shop/index\.jsp\ HTTP/ [NC] <------------ IS THIS RewriteCond REDUNTANT RewriteCond %{SERVER_PORT} ^8080$ RewriteCond %{QUERY_STRING} ^name=abc$ <------------ Should there be a ? -> ^?name=abc$ RewriteRule ^.*index.jsp [newHost:10080...]
Apache does not like this. I would very much appreciate any thoughts re this.
Thanks very much!
jdMorgan
7:50 pm on Feb 17, 2011 (gmt 0)
One or the other of the first two rewriteconds should work, depending on what you're trying to do here. Delete or comment-out the one that you don't need.