# Rewrite help when files do NOT have a ".php" extension

**URL:** <https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727>\
**Category:** NGINX\
**Created:** [June 1, 2011, 2:01pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727 "2011-06-01T14:01:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [June 1, 2011, 2:01pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/1 "2011-06-01T14:01:25Z")

</div>

Loving Nginx so far! So much faster and leaner than Apache.

Apologies for this yet another Rewrite rule help after so many threads,  
but one of domains has a special need and I am struggling with Rewrite  
rules.

The logic is simple:

1. For anything in /site folder, it should treat the static files as it  
is, but all else is php (file names don’t have .php extension). Still  
further in this folder:

2. For the main folder “/” all URLs should be directed to  
“/site/redirect”.

Following is in URI examples, so that it easier to visualize:

(Lines starting with asterisks \*\* are already working)…

/abc —\> /site/redirect?u=abc  
/xyz —\> /site/redirect?u=xyz

\*\* /site/abc —\> /site/abc (as PHP file)  
\*\* /site/xyz —\> /site/xyz (as PHP file)

\*\* /site/1.gif —\> Served as it is, static  
\*\* /site/2.png —\> Served as it is, static

\*\* /site/private/abc —\> Inside http auth, serve as PHP  
/site/private/ —\> Inside http auth, serve as PHP  
/site/private/index

/site/wordpress/… —\> This is the usual wordpress thing…  
The apache rules used to be:  
  
RewriteEngine On  
RewriteBase /site/wordpress/  
RewriteCond %{REQUEST\_FILENAME} !-f  
RewriteCond %{REQUEST\_FILENAME} !-d  
RewriteRule . /site/wordpress/index.php [L]

Here is what I have tried so far. I am almost there:

```
# SERVE CACHE STATIC FILES FIRST
location ~*

```

.(xml|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|doc|xls|exe|ppt)$  
{  
try\_files $uri =404;  
expires max;  
access\_log off;  
log\_not\_found off;  
}

```
# http://nginx.org/en/docs/http/converting_rewrite_rules.html
location / {
    try_files
          $uri
          /site/redirect?u=$uri
          @fromphp
          =404;
}

# FOR ALL THE PHP HANDLING
location @fromphp {
  fastcgi_pass unix:/dev/shm/php5-fpm.MYDOMAIN.sock;
  fastcgi_index index;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME

```

$document\_root$fastcgi\_script\_name;  
fastcgi\_param PATH\_TRANSLATED  
$document\_root$fastcgi\_script\_name;  
fastcgi\_param SCRIPT\_NAME $fastcgi\_script\_name;  
}

```
# FOR THE REST OF THE WEBSITE
location /site/ {

    fastcgi_pass unix:/dev/shm/php5-fpm.MYDOMAIN.sock;
    fastcgi_index index;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME

```

$document\_root$fastcgi\_script\_name;  
fastcgi\_param PATH\_TRANSLATED  
$document\_root$fastcgi\_script\_name;  
fastcgi\_param SCRIPT\_NAME $fastcgi\_script\_name;

```
    location ~ /site/private/ {
      auth_basic "Restricted";
      auth_basic_user_file

```

/home/MYDOMAIN/.htpasswds/public\_html/site/private/passwd;  
}

```
    location ~ \.php$ {
      #NOTE: Set "cgi.fix_pathinfo = 0;" in php.ini
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass

```

unix:/dev/shm/php5-fpm.MYDOMAIN.sock;  
fastcgi\_intercept\_errors on;  
fastcgi\_index index.php;  
fastcgi\_param SCRIPT\_FILENAME  
$document\_root$fastcgi\_script\_name;  
fastcgi\_param PATH\_TRANSLATED  
$document\_root$fastcgi\_script\_name;  
fastcgi\_param SCRIPT\_NAME  
$fastcgi\_script\_name;  
}

```
    location ~ /site/wordpress/ {
      # Wordpress stuff
      try_files $uri $uri/ /site/wordpress/index.php?q=$uri&$args;
      if (-f $request_filename) { expires 30d; break; }
      if (-d $request_filename) { break; }
      if (!-e $request_filename) { rewrite ^/site/wordpress/(.+)$

```

/site/wordpress/index.php?q=$1 last; }  
}

```
}

```

Basically what is NOT working:

1. The main directory which is supposed to redirect to  
“/site/redirect?u=URI”
2. The Wordpress stuff is downloading a text file (with the full PHP  
code, which is scary)

Thanks for any ideas or pointers!

Posted at Nginx Forum:

> **[Rewrite help when files do NOT have a ".php" extension](https://forum.nginx.org/read.php?2,202956,202956#msg-202956)**
>
> Loving Nginx so far! So much faster and leaner than Apache. Apologies for this yet another Rewrite rule help after so many threads, but one of domains has a special need and I am struggling with Rewrite rules. The logic is simple: 1. For anything in...

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 1, 2011, 3:07pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/2 "2011-06-01T15:07:39Z")

</div>

On 1 Jun 2011 13h00 WEST, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> is, but all else is php (file names don’t have .php extension). Still  
> Following is in URI examples, so that it easier to visualize:
> 
> RewriteEngine On  
> RewriteBase /site/wordpress/  
> RewriteCond %{REQUEST\_FILENAME} !-f  
> RewriteCond %{REQUEST\_FILENAME} !-d  
> RewriteRule . /site/wordpress/index.php [L]

location / {  
rewrite ^/(.\*)$ /site/redirect?u=$1;  
}

location /site {  
location  
/site/.\*.(?:xml|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|doc|xls|exe|ppt)$  
expires max;  
access\_log off;  
log\_not\_found off;

}  
location /site/private {  
auth\_basic “Restricted”;  
auth\_basic\_user\_file  
/home/MYDOMAIN/.htpasswds/public\_html/site/private/passwd;  
  
}

location /site/wordpress {  
## Regular PHP processing.  
location ~ ^/site/wordpress/(?.+.php)(?\<path\_info\>.\*)$ {  
include fastcgi.conf;  
## The fastcgi\_params must be redefined from the ones  
## given in fastcgi.conf. No longer standard names  
## but arbitrary: named patterns in regex.  
fastcgi\_param SCRIPT\_FILENAME $document\_root$script;  
fastcgi\_param SCRIPT\_NAME $script;  
fastcgi\_param PATH\_INFO $path\_info;  
## Passing the request upstream to the FastCGI  
## listener.  
fastcgi\_pass unix:/dev/shm/php5-fpm.MYDOMAIN.sock;;  
}  
}  
}

location /site/redirect {  
  
}

## you need a try\_files directive here but your “desired” config is

## quite confusing and I don’t know what you need/want. Perhaps:

try\_files $uri $uri/ /site/wordpress; ## ???  
}

For the fastcgi block use nested locations and named captures like the  
above example, always prefixing the regex with the outer location  
string, like in the /site/wordpress location.

— appa

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 1, 2011, 3:32pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/3 "2011-06-01T15:32:27Z")

</div>

On 1 Jun 2011 14h23 WEST, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks so much appa. In your suggested example, is there an opening  
> bracket after "location

/site/.\*.(?:xml|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|doc|xls|exe|ppt)$"

> ?

Yes there _should_ be one {. I forgot that.

location  
/site/.\*.(?:xml|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|doc|xls|exe|ppt)$  
{  
(…)  
}

> I got confused a bit with the blocks structure there.

It looks confusing but in fact is clearer since you’re reducing your  
exposure to potential config bugs due to unwanted side effects of  
regex based locations.

> Will try some of this, and get back with results here especially  
> related to the last “try\_files” bit. I didn’t fully comprehend what  
> you are suggesting, but let me read it some more times and try  
> stuff.

— appa

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 1, 2011, 3:23pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/4 "2011-06-01T15:23:47Z")

</div>

Thanks so much appa. In your suggested example, is there an opening  
bracket after “location  
/site/.\*.(?:xml|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|doc|xls|exe|ppt)$”  
?

I got confused a bit with the blocks structure there.

Will try some of this, and get back with results here especially related  
to the last “try\_files” bit. I didn’t fully comprehend what you are  
suggesting, but let me read it some more times and try stuff.

Posted at Nginx Forum:

> **[Re: Rewrite help when files do NOT have a ".php" extension](https://forum.nginx.org/read.php?2,202956,202980#msg-202980)**
>
> Loving Nginx so far! So much faster and leaner than Apache. Apologies for this yet another Rewrite rule help after so many threads, but one of domains has a special need and I am struggling with Rewrite rules. The logic is simple: 1. For anything in...

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 1, 2011, 4:25pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/5 "2011-06-01T16:25:41Z")

</div>

On 1 Jun 2011 15h03 WEST, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> #----------------  
> $document\_root$fastcgi\_script\_name;  
> fastcgi\_param PATH\_TRANSLATED  
> $document\_root$fastcgi\_script\_name;  
> fastcgi\_param SCRIPT\_NAME $fastcgi\_script\_name;  
> }
> 
> try\_files $uri $uri/ /site/get?u=$uri =404;
> 
> } # END OF SITE BLOCK  
> #----------------

This won’t work unless you have defined the name of the script that is  
to be executed by the upstream fastcgi process.

What is the name of the script that receives the u argument? get.php?  
index.php?

> Questions:
> 
> (1) What am I missing here? The “fastcgi\_params” is a file that has  
> the  
> usual bits and pieces.

Yes.

> (2) Will a more precise regexp like above be faster, or should i  
> leave  
> it as “(.\*)”?

I don’t think it will make much of a difference. But I’m not privy to  
the details of libpcre implementation. Perhaps Igor or Maxim can shed  
more light on that.

Of course the more specific you are the better it is in a security  
sense at least, IMHO.

— appa

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 1, 2011, 4:03pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/6 "2011-06-01T16:03:26Z")

</div>

Sorry edogawan. That was funny 🙂

Appa, yes I agree, it is much clearer with the blocks now making sense.

NOT working though. I will deal with Wordpress etc later. Want my root  
folder stuff to work first. Here are my simple rules.

#----------------  
location / {  
rewrite ^/([-~a-zA-Z0-9\_.]+)$ /site/get?u=$1;  
}

```
location /site {

    location /site/get {
      fastcgi_pass unix:/dev/shm/php5-fpm.MYDOMAIN.sock;
      include fastcgi_params;
      fastcgi_param SCRIPT_FILENAME

```

$document\_root$fastcgi\_script\_name;  
fastcgi\_param PATH\_TRANSLATED  
$document\_root$fastcgi\_script\_name;  
fastcgi\_param SCRIPT\_NAME $fastcgi\_script\_name;  
}

```
   try_files $uri $uri/ /site/get?u=$uri =404;

} # END OF SITE BLOCK

```

#----------------

Questions:

(1) What am I missing here? The “fastcgi\_params” is a file that has the  
usual bits and pieces.

(2) Will a more precise regexp like above be faster, or should i leave  
it as “(.\*)”?

Thanks@

Posted at Nginx Forum:

> **[Re: Rewrite help when files do NOT have a ".php" extension](https://forum.nginx.org/read.php?2,202956,202993#msg-202993)**
>
> Loving Nginx so far! So much faster and leaner than Apache. Apologies for this yet another Rewrite rule help after so many threads, but one of domains has a special need and I am struggling with Rewrite rules. The logic is simple: 1. For anything in...

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 1, 2011, 4:32pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/7 "2011-06-01T16:32:29Z")

</div>

António P. P. Almeida Wrote:

> This won’t work unless you have defined the name  
> of the script that is  
> to be executed by the upstream fastcgi process.
> 
> What is the name of the script that receives the u  
> argument? get.php? index.php?

Oh I see. I had totally misunderstood how this works.

The name of the script is “/site/get”. Without the .php extension.

And the uri should be passed as “?u=” and in some case there will be a  
second variable “&sb=”. The rewrite rules will work this way:

#--------------  
location / {  
rewrite ^/([-~a-zA-Z0-9\_.]+)(.+)$ /site/get?u=$1&sb=$2;  
rewrite ^/([-~a-zA-Z0-9\_.]+)$ /site/get?u=$1;  
}  
#--------------

So basically I can do the upstream bit this way?

#--------------  
include fastcgi\_params;  
fastcgi\_param SCRIPT\_FILENAME $document\_root$/site/get;  
fastcgi\_param PATH\_TRANSLATED $document\_root$/site/get;  
#--------------

Thanks for any ideas. (This is not working)

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,202956,203003#msg-203003](http://forum.nginx.org/read.php?2,202956,203003#msg-203003)

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 1, 2011, 5:30pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/8 "2011-06-01T17:30:39Z")

</div>

It’s not working. Keeps sending me back to “/site/index”.

Let me see if I can install nginx with the debug module and post back  
here. Or is it easier to install the echo module?

Posted at Nginx Forum:

> **[Re: Rewrite help when files do NOT have a ".php" extension](https://forum.nginx.org/read.php?2,202956,203025#msg-203025)**
>
> Loving Nginx so far! So much faster and leaner than Apache. Apologies for this yet another Rewrite rule help after so many threads, but one of domains has a special need and I am struggling with Rewrite rules. The logic is simple: 1. For anything in...

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 1, 2011, 4:55pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/9 "2011-06-01T16:55:24Z")

</div>

On 1 Jun 2011 15h32 WEST, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> rewrite ^/([-~a-zA-Z0-9\_.]+)(.+)$ /site/get?u=$1&sb=$2;  
> #--------------  
> Then use an exact location:

location = /site/get {  
include fastcgi\_params;

# Where’s the fastcgi\_pass directive?

fastcgi\_pass unix:/path/to/socket.sock;  
fastcgi\_param SCRIPT\_FILENAME $fastcgi\_script\_filename;  
}

I suggest you either use the echo module by agentzh or enable the  
error log with the debug flag to see what’s going on.

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

— appa

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 2, 2011, 12:12pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/10 "2011-06-02T12:12:03Z")

</div>

Thanks. I put this in my server directive:

```
  error_log logs/error.log debug;
  access_log logs/access.mine.log;
  log_format combined2 '$remote_addr - $remote_user [$time_local]

```

’  
'“$request” $status $body\_bytes\_sent ’  
‘“$http\_referer” “$http\_user\_agent”’;

But this creates a file “access.mine.log” which is empty. And the  
error\_log only manages to show me messages that are about the reloading  
of the nginx server (“[notice] 19142#0: signal process started”).

What can I do?

Posted at Nginx Forum:

> **[Re: Rewrite help when files do NOT have a ".php" extension](https://forum.nginx.org/read.php?2,202956,203242#msg-203242)**
>
> Loving Nginx so far! So much faster and leaner than Apache. Apologies for this yet another Rewrite rule help after so many threads, but one of domains has a special need and I am struggling with Rewrite rules. The logic is simple: 1. For anything in...

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 1, 2011, 5:44pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/11 "2011-06-01T17:44:16Z")

</div>

On 1 Jun 2011 16h30 WEST, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It’s not working. Keeps sending me back to “/site/index”.

> Let me see if I can install nginx with the debug module and post  
> back here. Or is it easier to install the echo module?

There’s no debug module. The error\_log directive is provided by the  
Main module. Which is a required module for any nginx build.

— appa

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 2, 2011, 9:28pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/12 "2011-06-02T21:28:49Z")

</div>

Regards to all  
I’m looking for a description of the Nginx Architecture in deep to work  
on a  
post on my blog about it.  
Where I can find it?

Thanks a lot

–  
Marcos Luis Ortiz Valmaseda  
Software Engineer (Distributed Systems)  
[http://uncubanitolinuxero.blogspot.com](http://uncubanitolinuxero.blogspot.com)

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 2, 2011, 10:13pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/13 "2011-06-02T22:13:55Z")

</div>

On 6/2/11, Marcos O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m looking for a description of the Nginx Architecture in deep to work on a  
> post on my blog about it.  
> Where I can find it?

I doubt it even exists. I remember there were some slides for nginx  
internals and Evan M.'s guide, but that’s about it.

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 2, 2011, 8:54pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/14 "2011-06-02T20:54:49Z")

</div>

On 2 Jun 2011 11h11 WEST, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> But this creates a file “access.mine.log” which is empty. And the  
> error\_log only manages to show me messages that are about the  
> reloading of the nginx server (“[notice] 19142#0: signal process  
> started”).
> 
> What can I do?

Did you configured the nginx build with the --with-debug option?

See [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/NginxDebugging)

— appa

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 3, 2011, 1:34am UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/15 "2011-06-03T01:34:40Z")

</div>

> Did you configured the nginx build with the  
> –with-debug option?
> 
> See [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/NginxDebugging)

Yes, this is what I was referring to earlier. Probably called it wrong,  
as “module”.

Mine is a production server. My reading suggests that “with-debug” the  
binary becomes quite large.

Anyway, is there absolutely no other way? The “error\_log /file debug”  
options is surprisingly useless.

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,202956,203478#msg-203478](http://forum.nginx.org/read.php?2,202956,203478#msg-203478)

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 3, 2011, 2:41am UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/16 "2011-06-03T02:41:53Z")

</div>

On 3 Jun 2011 00h33 WEST, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Mine is a production server. My reading suggests that “with-debug”  
> the binary becomes quite large.

I think that you’re confusing --with-debug and with _debugging  
symbols_. That’s two very different things. The later indeed generates  
a binary that is much larger.

Try it: --with-debug

— appa

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 2, 2011, 10:18pm UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/17 "2011-06-02T22:18:52Z")

</div>

Thanks, Alexandr  
That’s precisely I want to about on the blog post, to trying to explain  
in deep this because many people  
yet doesn’t understand why we use Nginx instead another web server.

Regards  
----- Mensaje original -----  
De: “Alexandr G.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Para: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Enviados: Jueves, 2 de Junio 2011 16:13:08 GMT -05:00 Región oriental  
EE. UU./Canadá  
Asunto: Re: Nginx Architecture in deep

On 6/2/11, Marcos O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m looking for a description of the Nginx Architecture in deep to work on a  
> post on my blog about it.  
> Where I can find it?

I doubt it even exists. I remember there were some slides for nginx  
internals and Evan M.'s guide, but that’s about it.

* * *

nginx mailing list  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> **[mailman.nginx.org archive](http://mailman.nginx.org/pipermail/)**

–  
Marcos Luís Ortíz Valmaseda  
Software Engineer (Large-Scaled Distributed Systems)  
Universidad de las Ciencias Informáticas  
Linux User # 418229

[http://uncubanitolinuxero.blogspot.com](http://uncubanitolinuxero.blogspot.com)

> **[Marcos Ortiz on about.me](https://about.me/marcosortiz)**
>
> I am a Product Marketing Manager in Havana, Cuba. Read my blog.

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 3, 2011, 3:46am UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/18 "2011-06-03T03:46:00Z")

</div>

On 3 Jun 2011 02h22 WEST, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> OK, I did this:
> 
> 1. Rebuilt nginx with “with-debug”

This is to be done in the configure phase of the build. It’s not a  
configuration thing. The only thig needed in the config is the debug  
flag in the error\_log directive.

You’re confusing two very different things.

> 1. Added another line to my nginx.conf:

> debug\_connection MY IP ADDRESS;

This means that only the requests from this IP generate the debug  
log. You need to build a local version on a dev box and debug the  
configuration there.

> 1. Then restarted the server.

A simple reload will do.

> My error\_log and access\_log are still empty after I visit several  
> pages of the website.
> 
> What else do I need to do?

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

— appa

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 3, 2011, 3:22am UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/19 "2011-06-03T03:22:34Z")

</div>

OK, I did this:

1. Rebuilt nginx with “with-debug”

2. Added another line to my nginx.conf:

3. Then restarted the server.

My error\_log and access\_log are still empty after I visit several pages  
of the website.

What else do I need to do?

Posted at Nginx Forum:

> **[Re: Rewrite help when files do NOT have a ".php" extension](https://forum.nginx.org/read.php?2,202956,203496#msg-203496)**
>
> Loving Nginx so far! So much faster and leaner than Apache. Apologies for this yet another Rewrite rule help after so many threads, but one of domains has a special need and I am struggling with Rewrite rules. The logic is simple: 1. For anything in...

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 3, 2011, 4:21am UTC](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727/20 "2011-06-03T04:21:18Z")

</div>

On 3 Jun 2011 03h08 WEST, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> to debug?  
> Are you making any request? You can do it through the browser, using  
> curl or wget.

If there’s no request, no debug log will be generated.

Make a request. Request the URI that should invoke the redirect  
script, and so on. Go step by step.

— appa

[Next page](https://www.ruby-forum.com/t/rewrite-help-when-files-do-not-have-a-php-extension/207727.md?page=2)
