惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
GbyAI
GbyAI
P
Proofpoint News Feed
Microsoft Security Blog
Microsoft Security Blog
月光博客
月光博客
I
InfoQ
V
Visual Studio Blog
罗磊的独立博客
Engineering at Meta
Engineering at Meta
Vercel News
Vercel News
Jina AI
Jina AI
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
The Cloudflare Blog
小众软件
小众软件
雷峰网
雷峰网
V
V2EX
人人都是产品经理
人人都是产品经理
Stack Overflow Blog
Stack Overflow Blog

博客园 - 隴上煙雨劍

什么是交叉验证 一句话设计模式 代理模式 中介模式 桥接模式 吐槽一下依赖倒置这个糟糕的名字 适配器模式 设计模式之状态模式 设计模式之装饰器模式 mysql插入数据如果存在则忽略 自己手写一个js的双向绑定 Java已经不再是以前的java了 无法访问9200端口的ElasticSearch服务 Forbidden You don't have permission to access / on this server [转帖]快速激活最新JetBrains公司系列产品包括最新的phpstorm10 VirtualBox在win8.1中无法安装64位虚拟机 多谢Mono Ubuntu14.04上面安装mono3.12版本 更新线上数据库时候的安全操作
【转】CI去掉index.php
隴上煙雨劍 · 2015-11-10 · via 博客园 - 隴上煙雨劍

感谢原作者:http://blog.csdn.net/spring21st/article/details/8334299

原文链接在:http://blog.csdn.net/spring21st/article/details/8334299

本人在apache2.4.9下亲测可用,感谢感谢。

--------------------------

由于使用的是windows开发环境,服务器用的是xampp,今天在做codeigniter 去掉index.php 的时候,需要用到apache的mod_rewrite.

首先需要配置下 Apache的mod_rewrite:

1. 在[Apache安装目录]/conf/httpd.conf中:

     找到#LoadModule rewrite_module modules/mod_rewrite.so,去掉前面的注释符号#。

     如果没有这行,请添加。并确认apache安装目录下的modules文件夹中是否有mod_rewrite.so这个文件。

     这样就启用了Mod Rewrite功能。


2. 在[Apache安装目录]/conf/httpd.conf中找到

  1. <Directory />  
  2.     Options FollowSymLinks  
  3.     AllowOverride None  
  4.     Order deny,allow  
  5.     Deny from all  
  6. </Directory>  

把“AllowOverride None”改成“AllowOverride All”,这样所有的文件夹都支持.htaccess了,或者针对指定的文件夹启用.htaccess,

可以在[Apache安装目录]/conf/httpd.conf中加入

  1. <Directory "D:/Program Files/xampp/htdocs/mss">  
  2.     Options Indexes FollowSymLinks  
  3.     AllowOverride All  
  4.     Order allow,deny  
  5.     Allow from all  
  6. </Directory>  

这种做法一般是和虚拟主机配置在一起的.

3. 我使用的是虚拟主机,所以第二步中的配置,我是在[Apache安装目录]/conf/extra/httpd-vhost.conf 中进行修改

  1. <VirtualHost *:80>  
  2.     ProxyPreserveHost On  
  3.     DocumentRoot "D:/Program Files/xampp/htdocs/mss"  
  4.     ServerName  xxx.music.baidu.com  
  5.     DirectoryIndex index.php  
  6.     <Directory "D:/Program Files/xampp/htdocs/mss">   
  7.         Options Indexes FollowSymLinks   
  8.         AllowOverride All   
  9.         Order allow,deny   
  10.         Allow from all   
  11.     </Directory>  
  12. </VirtualHost>  

重启Apache,mod_rewrite 生效!

4. 剩下是codeigniter的修改,it's very important!!!

将 .htaccess 修改为

  1. RewriteEngine on     
  2. RewriteCond $1 !^(index\.php|images|robots\.txt)     
  3. RewriteRule ^(.*)$ /index.php/$1 [L]  

然后移至网站根目录!(切记,否则还是访问还是无效的。)

其它操作系统下Apache rewrite配置可以参见: http://dancewithnet.com/2010/05/29/making-mod-rewrite-and-htaccess-work-on-mac-os-x/

版权声明:本文为博主原创文章,未经博主允许不得转载。