dingding:loveliness:
Kohana入门教程之二:部署 Kohana 系统
书接前回,上回说到如何安装 Kohana系统到最后一个简单的 Hello World的例子。Kohana入门教程之一的结尾已经完成了初步的部署工作。
1. 删除 URL上面的index.php
或许已经有朋友厌恶了每次调试页面都要加上一个index.php。而且使得整个URL也变的不是很美观,那么怎么样才能去掉它呢。没错使用.htaccess
文件设置,这个可是一个很伟大的文件,使用它不仅可以修改URL(实现伪静态化),同时可以可以保证系统的安全性!
那么什么是.htaccess呢?
.htaccess文件(或者"分布式配置文件"提供了针对目录改变配置的方法, 即,在一个特定的文档目录中放置一个包含一个或多个指令的文件, 以作用于此目录及其所有子目录。
更多请看这里:
[list]Apache指南: .htaccess文件
.htaccess使用指南
不要着急创建这个文件,原因有两点:
第一点是这个文件需要修改apache的配置才可以使用:httped.conf。
找到 LoadModule rewrite_module modules/mod_rewrite.so 去掉前面的#在把AllowOverride None改为 AllowOverride Options FileInfo 或者 AllowOverride All第二点,你试着尝试创建这个文件,是不是没有办法创建?呵呵,这个其实是Windows的一个问题,我们需要先打开一个txt文件,然后把下面的代码添加进入,最后再另存为,在.htaccess的前后加上双引号(英文状态)
# Turn on URL rewriting RewriteEngine On # Put your installation directory here: # If your URL is www.example.com/kohana/, use /kohana/ # If your URL is www.example.com/, use / RewriteBase /kohana/ # Protect application and system files from being viewed RewriteCond $1 ^(application|system) # Rewrite to index.php/access_denied/URL RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L] # Allow these directories and files to be displayed directly: # - index.php (DO NOT FORGET THIS!) # - robots.txt # - favicon.ico # - Any file inside of the images/, js/, or css/ directories RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|images|js|css) # No rewriting RewriteRule ^(.*)$ - [PT,L] # Rewrite all other URLs to index.php/URL RewriteRule ^(.*)$ index.php/$1 [PT,L]再试着访问看看,把 http://localhost/kohana/index.php/examples 改成 http://localhost/kohana/examples
成功了吧!
如果还没有明白,那么出杀手锏!视频教程:
下载【清晰版】 | 下载【压缩版】
2. config.php
直接看汉化版的配置文件吧:
配置文件 - http://khnfans.cn/docs/general/configuration
dingding:loveliness:
多谢楼主哈
...................................................................
看看 顶顶
看看 谢谢 呵呵
试了一下,果然很好用。呵呵。谢谢啦。
从没见过这么详细贴切的教程
正需要能 看看先
设置了怎么还是不行啊,还是要看看视频教程
1# icyleaf
太牛XX了。
修改后不成功
look ,look
我要看看杀手锏
支持一下 谢谢楼主
iis 不支持 .htaccess 所以 iis的朋友就不要试了 如果需要使用,可以使用ISAPI
今天特意装了apache2.2试试 一切ok 赞一个!
Windows 平台有集成开发环境的啊
。。。。。。。。。。
新人....顶......
楼主做得蛮详细的。谢谢!
要修改哪里?
hao wen,
多学习啊
。。。。如果你在虚拟主机呢你没有权限,怎么处理这个方法不实用啊
发表讨论