Welcome! Log In Create A New Profile

Advanced

Re: RewriteCond command

António P. P. Almeida
February 02, 2011 12:04AM
On 2 Fev 2011 04h12 WET, nginx-forum@nginx.us wrote:

> 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
>

Try this:

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

>
> 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;

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;

> 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

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


_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

RewriteCond command

lifeisjustabout February 01, 2011 06:27PM

Re: RewriteCond command

António P. P. Almeida February 01, 2011 09:32PM

Re: RewriteCond command

lifeisjustabout February 01, 2011 10:24PM

Re: RewriteCond command

António P. P. Almeida February 02, 2011 12:04AM

Re: RewriteCond command

lifeisjustabout February 02, 2011 01:10AM

Re: RewriteCond command

lifeisjustabout February 02, 2011 04:43AM

Re: RewriteCond command

Igor Sysoev February 02, 2011 05:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 305
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready