Forum Moderators: phranque
Working URL and code (URL part that changes is shown as ZZZ)....
cgi-local-file.cgi-myOperation=Used&ItemId=ZZZ/Page/ZZZ
Options +Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^cgi-local-fille.cgi-myOperation=Used&ItemId=(.*)/Page/(.*)$ cgi-local/file.cgi?myOperation=Used&ItemId=$1&ItemPage=$2 [L]
Non working URL that I'm trying to get to work, the code, and error message....
cgi-local/file.cgi?myOperation=Used&ItemId=ZZZ/Page/ZZZ
RewriteRule ^cgi-local/file.cgi?myOperation=Used&ItemId=(.*)/Page/(.*)$ cgi-local/file.cgi?myOperation=Used&ItemId=$1&ItemPage=$2 [L]
Error message on page: ZZZ/Page/ZZZ is not a valid value for ItemId. Please change this value and retry your request.
The part that is messing it up is having
cgi-local/file.cgi?
on the left before the $
The / and ? mess it up.
How do I get this to work? I even tried having a \ before both the / and ? .
Trying
RewriteRule ^cgi-local(.*)amazon_products_feed.cgi(.*)myOperation=Used&ItemId=(.*)/Page/(.*)$ cgi-local$1amazon_products_feed.cgi$2myOperation=Used&ItemId=$3&ItemPage=$4 [L]
and
RewriteRule ^(.*)myOperation=Used&ItemId=(.*)/Page/(.*)$ $1myOperation=Used&ItemId=$3&ItemPage=$4 [L]
also didn't make it work. I also tried
RewriteRule ^cgi-local(.*)file.cgi(.*)$ cgi-local$1file.cgi$2 [L]
but that's a loop that suddenly hogs about half the servers CPU, and I had to kill it in SSH top. (Stop it in the browser and it keeps going.)
In order to test query strings in mod_rewrite, you can use
RewriteCond %{QUERY_STRING} ^ItemID=(ID_here)$
Jim
RewriteCond %{QUERY_STRING} ^ItemID=B000059H9A$
RewriteRule ^cgi-local/file.cgi?myOperation=Used&ItemId=(.*)/Page/(.*)$ cgi-local/file.cgi?myOperation=Used&ItemId=%1&ItemPage=$2 [L]
It's not that part that's messing it up, but the
cgi-local/file.cgi?
part. The / and ? mess it up.
cgi-local-file.cgi-myOperation=Used&ItemId=ZZZ/Page/ZZZ
and
RewriteRule ^cgi-local-file.cgi-myOperation=Used&ItemId=(.*)/Page/(.*)$ cgi-local/file.cgi?myOperation=Used&ItemId=$1&ItemPage=$2 [L]
do work. Notice the two -'s instead of / and ?
RewriteRule ^cgi-local-file.cgi-myOperation=Used&ItemId=(.*)/Page/(.*)$ cgi-local/file.cgi?myOperation=Used&ItemId=$1&ItemPage=$2 [L]
RewriteRule ^cgi-local/file.cgi?myOperation=Used&ItemId=(.*)/Page/(.*)$ cgi-local/file.cgi?myOperation=Used&ItemId=$1&ItemPage=$2 [L]
RewriteCond %{QUERY_STRING} ^ItemId=([^/]*)/Page/(.*)
RewriteRule ^cgi-local/file.cgi$ /cgi-local/file.cgi?myOperation=Used&ItemId=%1&ItemPage=%2 [L]
Jim
This works.
RewriteRule ^cgi-local-file.cgi-test$ /cgi-local/file.cgi?real
domain.com/cgi-local-file.cgi-test
But this doesn't.
RewriteRule ^cgi-local/file.cgi?test2$ /cgi-local/file.cgi?real
domain.com/cgi-local/file.cgi?test2
What would I change to get this one to work?