Forum Moderators: phranque
i could hack the cms code to force the links which should be http to be sent to the browser that way, but i'd rather produce a more general solution.
i've pulled my hair out with mod_rewrite, and now i've found that RedirectMatch should be able to accomplish the same thing much more simply - but i'm also having trouble with that. both modules are available to me via .htaccess.
here's a simple example of something i can't make work:
#/.htaccess:
RedirectMatch 301 (.*)contact(.*) [google.com...]
at this point i'm not even worried about the substitutions - i just want any url that contains the string "contact" to redirect to google.
please tell me what i'm doing wrong. or any suggestions for how to handle my situation overall would be greatly appreciated.
thanks
what i want to do is something like this:
RewriteCond %{query_STRING} ^(.*)keyword(.*)
RewriteRule ^(.*) [mysite.com...] [R=301, L]
what i'd like to say here is: "any time a query string contains <keyword> force the use of http (port 80)", but this doesn't seem to be working.
any advice?...i feel like i'm getting close.
thanks.
for anyone else trying to do something similar, i ended up solving this like so:
RewriteCond %{query_STRING} (.*)keyword(.*)$
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*) http://mysite.com/$1 [R=301,L]
without the "RewriteCond %{SERVER_PORT} 443" an infinite loop can be generated...
cheers.
Welcome to WebmasterWorld.
Sorry for the delay in the response, many of the regulars are out of town and I have found myself BUSY this last week.
RewriteCond %{query_STRING} (.*)keyword(.*)$
If you are not needing to 'store' variables your condition would be much more efficient by using the implicit 'anything before' keyword 'and anything after'. The regular expression .* is inherantly GREEDY.
This is accomplished by leaving the opening and closing of the line off:
RewriteCond %{QUERY_STRING} keyword
if you would like to test the end of the line for the keyword, you could use this:
RewriteCond %{QUERY_STRING} keyword$
and for the beginning you should be able to use something like this:
RewriteCond %{QUERY_STRING} ^variable=keyword
Hope this helps.
Justin