phalcon的nginx重写实现模仿apache下的.htaccess

#  power by www.phpStudy.net 
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘
    #                  ‘$status $body_bytes_sent "$http_referer" ‘
    #                  ‘"$http_user_agent" "$http_x_forwarded_for"‘;

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    #tcp_nodelay on;
  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 128k;
  fastcgi_buffers 4 128k;
  fastcgi_busy_buffers_size 256k;
  fastcgi_temp_file_write_size 256k;

  #gzip  on;
  gzip on;
  gzip_min_length  1k;
  gzip_buffers     4 32k;
  gzip_http_version 1.1;
  gzip_comp_level 2;
  gzip_types       text/plain application/x-javascript text/css application/xml;
  gzip_vary on;
  gzip_disable "MSIE [1-6].";

  server_names_hash_bucket_size 128;
  client_max_body_size     100m; 
  client_header_buffer_size 256k;
  large_client_header_buffers 4 256k;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        root   "D:/WWW";
        location / {
            index  index.html index.htm index.php l.php;
           autoindex  off;
        }

        #error_page  404              /404.html;

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

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php(.*)$  {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }

		location /jiazu/ {
			rewrite ^/jiazu/(.*) /jiazu/public/index.php last;
		}
        # deny access to .htaccess files, if Apache‘s document root
        # concurs with nginx‘s one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

include vhosts.conf;

}

以上是我的nginx配置文件,实现重写代码如下:

location /项目名称/ {
    rewrite ^/项目名/(.*) /项目名称/public/index.php last;
}

OK大工告成,三行代码搞定phalcon重写

时间: 2024-08-28 00:33:19

phalcon的nginx重写实现模仿apache下的.htaccess的相关文章

nginx和apache下的url rewrite

将服务器上面的数据同步到本地之后,发现打开首页显示不正常,本地服务器是apache,经过打开url rewrite之后本地首页正常显示. 原因是phpwind本身支持了url rewrite的功能,但是本地的apache服务器没有开启这项功能,导致了首页的排版紊乱. 远程服务器用的的nginx和本地的apache的url rewrite配置不能通用,借此机会学习下,url rewrite的功能. url rewrite是服务器的一个模块,功能包括,配置一些访问的网址的重写,其中的语句规则是基于正

Nginx/Apache下如何禁止指定目录运行PHP脚本

转自http://www.phpchina.com/portal.php?mod=view&aid=40248, 需获取更多资料请查看原文 网站程序的上传目录通常是不需要PHP执行解释权限,通过限制目录的PHP执行权限可以提网站的安全性,减少被攻击的机率. 下面和大家一起分享下如何在Apache和Nginx禁止上传目录里PHP的执行权限. Apache下禁止指定目录运行PHP脚本 在虚拟主机配置文件中增加php_flag engine off指令即可,配置如下 "/website/upl

解决一次由于SSL证书到期导致的网站不能访问的问题(Nginx,php,Apache)

1. 现象 放假期间收到zabbix报警,提示主站访问不了,报502. 2.排查思路及过程 因为是过年休息,放假前又没有更新,基本可以排除是更新和配置导致的问题.ssh连上服务器发现服务器连接和资源都没问题.这是一套lnamp架构的网站,就是nginx反向代理到Apache,所以考虑是Apache的问题,于是重启httpd服务. 重启httpd服务的时候启动失败,没有看到错误,所以去查看日志文件,看到如下报错: tail -200 /var/log/httpd/error_log [TIME 2

centos7安装Lnmp(Linux+Nginx+MySql+Php+phpMyAdmin+Apache)

centos7安装Lnmp(Linux+Nginx+MySql+Php)及Apache Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx是一个高性能的HTTP和反向代理服务器,Nginx 超越 Apache 的高性能和稳定性,使得国内使用 Nginx 作为 Web 服务器的网站也越来越多, 我们学习PHP,以及搭建我们自己的LNMP环境,不妨先在本机上尝试学习,下面我们一步一步来完成在CentOS7 下安装LNMP(Linux+Nginx+MySQL+PHP)及Apache. 查

nginx 反向代理 与 Apache backend的配置联合配置

nginx 反向代理 与 Apache backend的配置联合配置: 说明: nginx 将http映射到Apache上的特定子目录. 配置方法步骤: 1.  设置域名, 子域名映射到指定服务器ip, 2. nginx设置好server ,以及对应的目录, 或者 转发到指定Apache端口. server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/ht

apache下实现301永久性重定向的方法

因为博客是使用了www.php100.com作为博客域名,所以想实现php100.com全部重定向(跳转)到www.php100.com.同时按照google的建议,使用服务器端 301 重定向,为了确保用户及搜索引擎定向至正确网页的最佳方法.301 状态代码表示某网页已被永久迁移至新位置.下面将了解一下apache下实现301永久性重定向2个方法,需要具有访问服务器的 .htaccess 文件的权限. 1. Apache模块 mod_alias的 Redirect 和 RedirectMatc

使用Apache下poi创建和读取excel文件

一:使用apache下poi创建excel文档 1 @Test 2 /* 3 * 使用Apache poi创建excel文件 4 */ 5 public void testCreateExcel() { 6 // 1:创建一个excel文档 7 HSSFWorkbook workbook = new HSSFWorkbook(); 8 // 2:创建一个sheet工作表,名为“学生成绩” 9 HSSFSheet sheet = workbook.createSheet("学生成绩");

Apache下的配置文件httpd.conf、httpd-vhosts.conf 转

Apache下的配置文件httpd.conf.httpd-vhosts.conf(windows) 2013-05-24 22:09 by youxin, 58 阅读, 0 评论, 收藏, 编辑 httpd.conf文件一般存在于apache目录下的conf文件夹中,主要用来配置apache的.http.conf里面的配置介绍: 1.Listen :监听端口,默认情况是80. 2.ServerAdmin :服务器管理员邮箱. 3.ServerName:服务名. 4.DocumentRoot:PH

模仿ios下的coverflow

Android高级图片滚动控件,编写3D版的图片轮播器 http://blog.csdn.net/guolin_blog/article/details/17482089 A cool Open Source CoverFlow view for Android with several fancy effects. https://github.com/davidschreiber/FancyCoverFlow 模仿ios下的coverflow,布布扣,bubuko.com