Forum: NGINX Need help with converting from Apache.

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ian H. (Guest)
on 2009-04-18 23:39
(Received via mailing list)
Hi All,

I have a site that uses phpcms - and the nginx setup for it is below -
and it works.

server {
    listen   80;
    server_name ;
    root /var/www/;
    index index.php index.html index.htm;
    access_log /var/www/;

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;

    # send  (*.htm)  to /parser/parser.php?file=%1
    location ~* \.htm$ {
       rewrite ^(.*\.htm)$ /parser/parser.php?file=$1;
    # all .php requests to fastcgi
    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
    #  request password for stats
    location ^~ /usage/ {
        auth_basic "Hello, please login";
        auth_basic_user_file /var/www/;

When apache was serving the site, the /parser directory had a .htaccess
file in it that stopped any files being served, but it did not stop the
for /parser/parser.php?params  being actioned via the rewrite.

How can I add the same here?



p.s nginx version  0.6.35
Ian H. (Guest)
on 2009-04-20 14:01
(Received via mailing list)
Bump. Anybody.

How can I let php execute /parser/parser.php and stop nginx serving
anything else in /parser and sub-directories, except
/parser/gif/* which should be permitted?


SSSlippy (Guest)
on 2009-04-21 17:55
(Received via mailing list)
If you are trying to stop direct requests to a directory the best way is
to remove the directory from a web accessible area and then have the
script access the non web accessible area.

Posted at Nginx Forum:,1176,1213#msg-1213
This topic is locked and can not be replied to.