rewrite help please...

Steve Holdoway steve at greengecko.co.nz
Sun Dec 9 20:51:00 UTC 2012


On Sun, 2012-12-09 at 10:29 +0000, Francis Daly wrote:

> 
> Given your above configuration, am I right that what you want is:
> 
> http://www.example.com/ -> php-process /usr/local/nginx/html/index.php
> http://www.example.com/index.php -> php-process /usr/local/nginx/html/index.php
> http://www.example.com/file.png -> send /usr/local/nginx/html/file.png
> http://www.example1.com/ -> php-process /usr/local/nginx/html/link/example1/index.php
> http://www.example1.com/index.php -> php-process /usr/local/nginx/html/index.php
> http://www.example1.com/file.png -> send /usr/local/nginx/html/file.png
> 
> where in each case "send" or "php-process" means "respond http 200 with
> the output of that file"?
> 
> > As the comment says, this does work if I use a rewrite ... redirect; but
> > the URL then changes to http://www.example1.com/link/example1, whereas I
> > want to see http://www.example1.com alone.
> > 
> > The try_files comes up with a 404, which is really perplexing... I
> > expected it to go through the .php block like the others!
> 
> After "location -> if -> anything else", I find it's usually not worth
> wondering why things do or don't work as hoped. You're in "here be
> dragons" territory anyway. That's nginx.
> 
> > Any ideas what I'm doing wrong?
> 
> With the assumptions and changes from above, maybe
> 
>   location = / {
>     fastcgi_pass unix:php.sock;
>     include fastcgi_params;
>     fastcgi_param SCRIPT_FILENAME $document_root$page_redirect;
>   }
> 
> is closer to what you want?
> 
> Good luck with it,

Thanks for the ideas Francis, it's cleaned up my config no end!

This is a WordPress site, so all requests have to go to /index.php to be
processed. The URL dictates the page returned. 

I can't seem to find a way of mimicing what I'm trying to do with your
method, no matter what fastcgi_params I try setting up.

Cheers,


Steve

-- 
Steve Holdoway BSc(Hons) MIITP 
http://www.greengecko.co.nz
Skype: sholdowa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 6189 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20121210/20870ac1/attachment.bin>


More information about the nginx mailing list