RewriteCond command

hi i’ve seen many example that answered this forum and they use
RewriteCond but if i put that command i get error nginx 0.8.3

RewriteCond %{request_uri} !^index.php

if put my conf file it says

[emerg]: unknown directive “RewriteCond” in …

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,171397,171397#msg-171397

On 2 Fev 2011 02h11 WET, [email protected] wrote:

hi i’ve seen many example that answered this forum and they use
RewriteCond but if i put that command i get error nginx 0.8.3

RewriteCond %{request_uri} !^index.php
^^^^^^^^^^^

This an Apache mod_rewrite thing.

There’s no equivalent in Nginx. It uses a saner, more clear approach
of a single condition + rule in Apache terms.

Cf. http://wiki.nginx.org/HttpRewriteModule

— appa

thanks Antonio

if i could find to change & to ? i am going to solve my problem

incorrect
http://www.mysite.com/search/web&search=katy%20perry&type=web

correct
http://www.mysite.com/search/web?search=katy%20perry&type=web

what should i add into my conf
server {
listen 81;
server_name *.mysite.ws;
access_log /var/log/mysite.access.log main;
error_log /var/log/mysite.error.log;
root /home/mysite/www;
index index.php index.html;

rewrite /(.)(style.css)$ /$2 last;
rewrite /(.
)(lightbox.css)$ /$2 last;
rewrite /(.)(userdata/)(.)$ /$2$3 last;
rewrite /(.)(maps/)(.)$ /$2$3 last;
rewrite /(.)(test/)(.)$ /$2$3 last;
rewrite ^/(.)(index.php)(/?)(.)$ /index.php?page=index/$4 last;
rewrite /(.)(install/)(.)$ /$2$3 last;
rewrite /(.)(addon/)(.)$ /$2$3 last;
rewrite /(.)(cron/)(.)$ /$2$3 last;
rewrite /(.)(js/)(.)(.js)$ /$2$3$4 last;
rewrite /(.)(images/)(.)(.)(gif|jpe?g|png|ico)$ /$2$3$4$5 last;
rewrite ^/(.*)$ /index.php?page=$1 last;

location / {
try_files $uri $uri/ /index.php?q=$request_uri;
}

location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/mysite/www$fastcgi_script_name;
include fastcgi_params;
}
}

i couldnt convert this into my conf

RewriteCond %{request_uri} !^index.php

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,171397,171425#msg-171425

thanks Antonio its been fixed

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,171397,171484#msg-171484

On 2 Fev 2011 04h12 WET, [email protected] wrote:

Try this:

location /search/web {
rewrite ^ /search/web?$args?;
}

rewrite /(.)(style.css)$ /$2 last;
rewrite ^/(.
)$ /index.php?page=$1 last;
There’s room for improvement above. You have rules that are repeated,
it just changes the second pattern. E.g.,

rewrite /(.)(maps/)(.)$ /$2$3 last;
rewrite /(.)(test/)(.)$ /$2$3 last;
rewrite /(.)(install/)(.)$ /$2$3 last;
rewrite /(.)(addon/)(.)$ /$2$3 last;
rewrite /(.)(cron/)(.)$ /$2$3 last;

Can be placed in a single rule:

rewrite /(.)((maps|test|install|addon|cron)/)(.)$ /$2$3 last;

}
}

i couldnt convert this into my conf

RewriteCond %{request_uri} !^index.php

This is just the condition, what’s the rule?

if ($request_uri != index.php) {
(…)
}

Note that an if is in fact an implicit location, so the only safe
thing to do inside is to return a status code or a rewrite with the
‘last’ flag. Cf. http://wiki.nginx.org/IfIsEvil

— appa

Hi Antonio,

thanks for your answer i added your code into conf but still didnt help
when i type something in textbox system try to autocomplate i think
livesearch but when you put space after a word its getting error, when i
see access log i am receiving this

i try to search kylie i am typing kylie
xx.xx.xx.xx - - [02/Feb/2011:16:58:37 +1100] “GET
/index/livesearch&q=k&type=web HTTP/1.1” 200 491
http://www.mysite.ws:81/” "Mozilla/5.0 (Windows; U; Wind$
xx.xx.xx.xx - - [02/Feb/2011:16:58:38 +1100] “GET
/index/livesearch&q=ky&type=web HTTP/1.1” 200 31
http://www.mysite.ws:81/” "Mozilla/5.0 (Windows; U; Wind$
xx.xx.xx.xx - - [02/Feb/2011:16:58:38 +1100] “GET
/index/livesearch&q=kyl&type=web HTTP/1.1” 200 31
http://www.mysite.ws:81/” "Mozilla/5.0 (Windows; U; Win$
xx.xx.xx.xx - - [02/Feb/2011:16:58:38 +1100] “GET
/index/livesearch&q=kyli&type=web HTTP/1.1” 200 31
http://www.mysite.ws:81/” "Mozilla/5.0 (Windows; U; Wi$
xx.xx.xx.xx - - [02/Feb/2011:16:58:39 +1100] “GET
/index/livesearch&q=kylie&type=web HTTP/1.1” 200 31
http://www.mysite.ws:81/” "Mozilla/5.0 (Windows; U; W$
xx.xx.xx.xx - - [02/Feb/2011:16:58:39 +1100] “POST /search/redir
HTTP/1.1” 302 5 “http://www.mysite.ws:81/” "Mozilla/5.0 (Windows; U;
Windows NT 6.1; en-GB;$
xx.xx.xx.xx - - [02/Feb/2011:16:58:41 +1100] “GET
/search/web?search=kylie&type=web&fl=0 HTTP/1.1” 200 13148
http://www.mysite.ws:81/” "Mozilla/5.0 (Window$
xx.xx.xx.xx - - [02/Feb/2011:16:58:44 +1100] “GET
/search/web?search=kylie&type=web&fl=0 HTTP/1.1” 200 13148
http://www.mysite.ws:81/” "Mozilla/5.0 (Window$
xx.xx.xx.xx - - [02/Feb/2011:16:58:49 +1100] “GET / HTTP/1.1” 200 5078
http://www.mysite.ws:81/search/web?search=kylie&type=web&fl=0
"Mozilla/5.0 (Windows$

and then i hit enter it brings kylie results

i try to search kylie minogue i am typing kylie and space

xx.xx.xx.xx - - [02/Feb/2011:16:58:52 +1100] “GET
/index/livesearch&q=k&type=web HTTP/1.1” 200 491
http://www.mysite.ws:81/” "Mozilla/5.0 (Windows; U; Wind$
xx.xx.xx.xx - - [02/Feb/2011:16:58:52 +1100] “GET
/index/livesearch&q=ky&type=web HTTP/1.1” 200 277
http://www.mysite.ws:81/” "Mozilla/5.0 (Windows; U; Win$
xx.xx.xx.xx - - [02/Feb/2011:16:58:52 +1100] “GET
/index/livesearch&q=kyl&type=web HTTP/1.1” 200 276
http://www.mysite.ws:81/” "Mozilla/5.0 (Windows; U; Wi$
xx.xx.xx.xx - - [02/Feb/2011:16:58:53 +1100] “GET
/index/livesearch&q=kylie%20&type=web HTTP/1.1” 200 752
http://www.mysite.ws:81/” "Mozilla/5.0 (Windows; $

and getting error not found

Error: Requested page was not found!
Details: livesearch&q=kylie &type=web Action not found!
Home

This is just the condition, what’s the rule?

if ($request_uri != index.php) {
(…)
}

i think the rule is adding + request url if i dont put this command on
htaccess apache automaticly adding %20 between words on the result page
if i put this into htaccess its automaticly adding + between result
words on result page

for instance

http://www.mysite.com/search/web?search=katy+perry&type=web
with RewriteCond

http://www.mysite.com/search/web?search=katy%20perry&type=web
without RewriteCond

they both working btw

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,171397,171450#msg-171450

On Tue, Feb 01, 2011 at 09:11:03PM -0500, lifeisjustabout wrote:

hi i’ve seen many example that answered this forum and they use
RewriteCond but if i put that command i get error nginx 0.8.3

RewriteCond %{request_uri} !^index.php

This should be translated from Yoda backward style to nginx forward
style:

location = /index.php {

}

location / {

}


Igor S.
http://sysoev.ru/en/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs