码迷,mamicode.com
首页 > Web开发 > 详细

CI框架apache和nginx环境下面统一去掉路径URL后面的index.php

时间:2015-09-22 19:15:48      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

APACHE:

在apache下去掉url上的index.php折腾了好久 ,一直是访问css ,js,图片文件   you can‘t access files on server 之类的错误提示,apached的配置上说的是

把 AllowOverride  none 改成  AllowOverride All ,然后allow from all,一直不生效,可以跳转页面,但是样式,js文件,图片都丢失,

发现还是.htaccss的RewriteCond出现了问题,原来是目录不对。

原先的样式文件,图片文件,js文件都放在application/views/templates下面了,后来改成一个和application同级的assets下面,如图:

技术分享

然后.htaccess文件里这样写


<IfModule mod_rewrite.c> 

RewriteEngine On  

RewriteBase /  

RewriteCond $1 !^(index\.php|assets|system|robots\.txt)    

RewriteRule ^(.*)$ /index.php/$1 [L,QSA]     

</IfModule>  

apache配置文件

<VirtualHost *:80>  
    ServerAdmin major2000@sina.com  
    DocumentRoot "d:/wnmp/web/myproject"  
      
    ServerName www.key.local  
      
    <Directory "d:/wnmp/web/myproject">    // 这里是项目的目录  
        Options Indexes MultiViews FollowSymLinks   
        AllowOverride All  
        Order allow,deny  
        allow from all  
   </Directory>  
</VirtualHost>  

NGINX里这样配置

location / {
   root   D:/wnmp/web/myproject/;
   index  index.php index.html index.htm;
   if (!-e $request_filename) {  
   rewrite ^/(.*)$ /index.php?$1 last;  
   break;  
   }  
}

CI框架apache和nginx环境下面统一去掉路径URL后面的index.php

标签:

原文地址:http://my.oschina.net/ailingling/blog/509723

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!