Forum Moderators: phranque
The "*" , as in regular expression, means "whatever".
I created the following rewrite rule:
RewriteRule ^/((.*)+(\.)+(cgi)+(=)+(forum)+(=)+(1000)+(&))+(.*) /index.html
This rule works when I enter address like this:
[localhost...]
My problem is that the “=” sign that is located after "cgi" should be "?",
But when I change it to "?" Inside the brackets I get an error while trying to restart Apache service.
I also tried it in the following syntax: (\?) but it doesn’t seem to work either.
I can't leave the rule as it is now because CGI requires a "?" before the variables.
I suppose that there is a solution to my problem, I just couldn't find it.
Please tell me, what is the right syntax for this kind of rule.
Thank you,
Gonen radai
[edited by: jdMorgan at 5:29 pm (utc) on Dec. 23, 2004]
[edit reason] No sigs, please. See TOS. [/edit]
and added \ before the . like that:
RewriteRule ^/((.*)+(\.)+(cgi)+(\.forum)+(=)+(1000)+(&))+(.*) /index.html
now when i enter the following address:
[localhost...]
i do get the right redirection, but i dont know if the wildcard . can replace? in CGI. can it?
Welcome to WebmasterWorld!
I suspect you're going about this process backwards, as it's far more usual to rewrite from a static URL to a dynamic URL with a query string.
If you do wish to rewrite from a dynamic URL to a static URL, you will have to handle the query string separately, since it is not part of a URL, but rather, data to be passed to the resource at that URL. See mod_rewrite's RewriteCond [httpd.apache.org] directive, and use the %{QUERY_STRING} server variable to capture, test, and create back-references to your query data.
Jim
i'll describe the problem further, so you might understand better, and be able to give me the best answer for my case:
i have a set of forums. some are free, others payed subscription on month/year basis.
when my main server is down (for any reason) i want the subscribers to be redirected to the backup server, and the rest (free forums) to get an ERROR PAGE or 404 or whatever. actually my main concern is the subscribers.
so if i have a dynamic address to:
www.mysite.com/somepage.cgi?forum=###&other-variables
i thought of creating rewrite rules (even if i'm talking about 100 rules)
that each one has the specific payed forum number, and redirect it to, let say, address like that:
backup.mysite.com/somepage.cgi?forum=###&other-variables
is rewriterule good for me?
do i need rewrite cond?
what would be the best solution for the situation?
thank you very much.
gonen.
If your main server is down, you can't redirect from it. Instead, you'd want to go change your DNS to point to the backup server. Set a short TTL (Time To Live) on these DNS entries, so that when you change the DNS, it will be picked up more quickly by the non-authoritative DNS servers.
If I miss your meaning about "server is down," and you mean it's in some state where it can still respond to some requests, then you can use RewriteCond %{QUERY_STRING} to match whatever forum numbers you want to forward to the other domain.
Jim
rewrite cond %{query string}, how do i implement this
using the following general syntax:
www.mysite.com/cgi-bin/forumsdb/intraforum_db.cgi?forum=2&read=&alias=dbr&redir_flag=
where the relevant string is :".cgi?forum=###&"
i don't care what comes before the .cgi
i don't care what comes after the &
and the ### could be different, not a range between 3-10 for example, but 43, 52, 88, 1005, 2039 and so on...
how should i write it?
thanks
RewriteCond %{QUERY_STRING} ^\.cgi?forum=###&$
RewriteCond %{QUERY_STRING} \.cgi?forum=###&$
RewriteCond %{QUERY_STRING} \.cgi?forum=###&
RewriteCond %{QUERY_STRING} \.cgi?forum=([0-9])+&
Please read our forum charter [webmasterworld.com] for more information.
Jim