Forum Moderators: phranque
I've tried quite a few rewrite rules as well.
RedirectMatch ^example1.com/results.php?&searchword=(.*) ......
^SERVER_NAMEThere exist situations where SERVER_NAME is needed, but this isn't one of them. Just use the regular domain name, example\.com, without anchors (because extraneous stuff like port numbers, and incorrect www, will all be taken care of in the redirect).
%{QUERY_STRING} ^&searchword=$This formulation will always fail, because ^ means "the very beginning of the test string", and I'm pretty sure your query string never begins with an ampersand (for "next parameter"). Worse, it would only succeed if "searchword=" came at the very end of the query, which normally wouldn't happen.
ReWriteRule ^results\.php\/\/\?\&searchword=(.*)I hope "ReWrite" was just a typo. Not everything is case sensitive, but why take chances. Slashes in mod_rewrite do not need to be escaped; neither do ampersands. Question marks do-- but as explained above, query strings cannot go in the body (pattern) of the rule. So the rule itself will always fail, even before the conditions are evaluated.
RewriteCond %{QUERY_STRING} searchword=([^&]*)
This capture then becomes %1 in the target. #3 The browser should now display
http://www.example.com/var/www/example.com/level1/level2/\?p=keywordsearch&term=blahblah
(using the physical filepath up to "example.com"). It's not what I expected, since there's supposed to be a default RewriteBase; go figure. But even if the RewriteBase did kick in as intended, the target would then be http://www.example.com/example.com/level1/level2/\?p=keywordsearch&term=blahblah
with two consecutive "example.com" because the server has no way of knowing that the one in the target is supposed to be a hostname. It thinks it's just another directory. ^search=1&start=0&max=20&searchword=([^&]*) http://example.com/results.php?search=1&start=0&max=20&searchword=mark_test searchword=([^&]*)
with no anchor at the front. Look only at the one parameter, ignoring the rest for now.