# Need help with converting from Apache

**URL:** <https://www.ruby-forum.com/t/need-help-with-converting-from-apache/165882>\
**Category:** NGINX\
**Created:** [April 18, 2009, 9:39pm UTC](https://www.ruby-forum.com/t/need-help-with-converting-from-apache/165882 "2009-04-18T21:39:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dcian](https://www.ruby-forum.com/u/dcian)\
**Post date:** [April 18, 2009, 9:39pm UTC](https://www.ruby-forum.com/t/need-help-with-converting-from-apache/165882/1 "2009-04-18T21:39:50Z")

</div>

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 [domain.com](http://domain.com)[www.domain.com](http://www.domain.com) ;  
root /var/www/domain.com/htdocs;  
index index.php index.html index.htm;  
access\_log /var/www/domain.com/access.log;

```
#
# 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;
    fastcgi_pass 127.0.0.1:9000;
}
# request password for stats
location ^~ /usage/ {
    auth_basic "Hello, please login";
    auth_basic_user_file /var/www/domain.com/passwords;

```

}  
}

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  
requests  
for /parser/parser.php?params being actioned via the rewrite.

How can I add the same here?

Thanks

Ian

p.s nginx version 0.6.35

---

<div class="post-metadata">

**Author:** ![dcian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dcian](https://www.ruby-forum.com/u/dcian)\
**Post date:** [April 20, 2009, 12:01pm UTC](https://www.ruby-forum.com/t/need-help-with-converting-from-apache/165882/2 "2009-04-20T12:01:47Z")

</div>

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?

Thanks

Ian

---

<div class="post-metadata">

**Author:** ![dcian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dcian](https://www.ruby-forum.com/u/dcian)\
**Post date:** [April 21, 2009, 3:55pm UTC](https://www.ruby-forum.com/t/need-help-with-converting-from-apache/165882/3 "2009-04-21T15:55:52Z")

</div>

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:

> **[Re: Need help with converting from Apache.](https://forum.nginx.org/read.php?2,1176,1213#msg-1213)**
>
> 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 domain.com www.domain.com ; root /var/www/domain.com/htdocs; index index.php
