---
title: "基于Nginx下的Joomla伪静态Rewrite配置[原创]"
author: "eryin"
date: "2010-04-09T10:49:05Z"
tags: ["Access", "CSS", "PHP", "Web", "nginx"]
categories: ["互联网"]
slug: "nginx-joomla-rewrite"
draft: false
lastmod: "2010-04-09T10:49:05Z"
id: 638927
url: "https://eryin.iteye.com/blog/638927"
---

配置文件具体如下，此配置文件已在某行业网站生产环境中实验成功。

 

user  www webuser;

worker\_processes 1;

error\_log  /web/logs/nginx\_error.log  crit;

pid        /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.  
worker\_rlimit\_nofile 65535;

events  
{  
  use epoll;  
  worker\_connections 65535;  
}

http  
{  
  include       mime.types;  
  default\_type  application/octet-stream;

  #charse  gb2312;

  server\_names\_hash\_bucket\_size 128;  
  client\_header\_buffer\_size 32k;  
  large\_client\_header\_buffers 1 128k;  
  client\_max\_body\_size 8m;

  sendfile on;  
  tcp\_nopush     on;

  keepalive\_timeout 60;

  tcp\_nodelay on;

  fastcgi\_connect\_timeout 300;  
  fastcgi\_send\_timeout 300;  
  fastcgi\_read\_timeout 300;  
  fastcgi\_buffer\_size 128k;  
  fastcgi\_buffers 8 128k;  
  fastcgi\_busy\_buffers\_size 256k;  
  fastcgi\_temp\_file\_write\_size 256k;  
  fastcgi\_intercept\_errors on;

  gzip on;  
  gzip\_min\_length  1k;  
  gzip\_buffers     1 64k;  
  gzip\_http\_version 1.0;  
  gzip\_comp\_level 2;  
  gzip\_types       text/plain application/x-javascript text/css application/xml;  
  gzip\_vary on;

  server  
  {  
    listen       203.130.37.35:80;  
    server\_name [www.luxee.com](http://www.luxee.com) luxee.com;  
    index index.php index.html index.htm;  
    root  /web/luxee/domains/new.luxee.com/public\_html/;

    location / {  
      if ( $args ~ "mosConfig\_\[a-zA-Z\_]{1,21}(=|\\%3d)" ) {  
      set $args "";  
        rewrite ^.\*$ [http://$host/index.php](http://%24host/index.php) last;  
      return 403;}

      if ( $args ~ "base64\_encode.\*\\(.\*\\)") {  
      set $args "";  
        rewrite ^.\*$ [http://$host/index.php](http://%24host/index.php) last;  
      return 403;}

      if ( $args ~ "(\\&lt;|%3C).\*script.\*(\\&gt;|%3E)") {  
      set $args "";  
        rewrite ^.\*$ [http://$host/index.php](http://%24host/index.php) last;  
      return 403;}

      if ( $args ~ "GLOBALS(=|\\\[|\\%\[0-9A-Z]{0,2})") {  
      set $args "";  
        rewrite ^.\*$ [http://$host/index.php](http://%24host/index.php) last;  
      return 403;}

      if ( $args ~ "\_REQUEST(=|\\\[|\\%\[0-9A-Z]{0,2})") {  
      set $args "";  
        rewrite ^.\*$ [http://$host/index.php](http://%24host/index.php) last;  
      return 403;}

      if (!-e $request\_filename) {  
        rewrite (/|\\.php|\\.html|\\.htm|\\.feed|\\.pdf|\\.raw|/\[^.]\*)$ /index.php last;  
      break;  
      }     
    }  
     
    location ~ .\*\\.(php|php5)?$  
    {  
      fastcgi\_pass  unix:/tmp/php-cgi.sock;  
      #fastcgi\_pass  127.0.0.1:9000;  
      fastcgi\_index index.php;  
      include fcgi.conf;  
    }

    location ~ .\*\\.(gif|jpg|jpeg|png|bmp|swf)$  
    {  
      expires      30d;  
    }

    location ~ .\*\\.(js|css)?$  
    {  
      expires      12h;  
    }

    access\_log  /web/logs/luxee.com-access.log;  
  }

}

本文来自：韦少乾博客(mven.cn)  
详细出处：[http://mven.cn/post/53.html](http://mven.cn/post/53.html)