zoukankan      html  css  js  c++  java
  • ci框架里rewrite示例

    ci里新建应用app,入口文件app.php。

    Nginx

    这里附上vhost配置

    app.52fhy.com.conf

    server {
    	listen       80;
    	server_name  app.52fhy.com;
    	index app.php;
    	root /www/test/ci/;
    	
    	location ~ .*.(php|php5)?$
    	{
    		#fastcgi_pass  unix:/tmp/php-cgi.sock;
    		fastcgi_pass  127.0.0.1:9000;
    		fastcgi_index app.php;
    		include fastcgi.conf;
    	}
    	
    	location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
    	{
    		expires 30d;
    	}
    	
    	location ~ .*.(js|css)?$
    	{
    		expires 1h;
    	}
    
    	location / {
    	  if (!-e $request_filename) {
                    rewrite ^/(.*)$ /app.php?/$1 last;
                    break;
              }
    	}
    	
    	access_log  /www/log/nginx/access/app.52fhy.com.log;
    }
    
    
    

    nginx重启命令为:

    /usr/local/nginx/sbin/nginx -s reload
    

    url访问示例:

    http://app.52fhy.com/Test/hello
    

    实际url为

    http://app.52fhy.com/app.php/Test/hello
    

    实现了隐藏入口文件的功能。

    Apache

    <IfModule mod_rewrite.c>
      Options +FollowSymlinks
      RewriteEngine On
    
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^(.*)$ /app.php/$1 [QSA,PT,L]
    </IfModule>
    
  • 相关阅读:
    c语言cgi笔记
    End of script output before headers错误解决方法
    我的树莓派3配置脚本
    Qt学习(4)
    Qt学习(3)
    Qt学习(2)
    Qt学习(1)
    C++ Primer中文版(第五版)——第六章 函数
    C++ 11 ----Lambda表达式
    Java SPI 源码解析
  • 原文地址:https://www.cnblogs.com/52fhy/p/5061314.html
Copyright © 2011-2022 走看看