步骤: 1. 建个项目 如下目录 application/ controllers/ ErrorController.php IndexController.php models/ views/ scripts/ index/ index.phtml helpers/ filters/ html/ .htaccess index.php 2.文件内容如下: IndexController.php 控制器
然后是html下面的 index.php 如下
建立好这些文件下面就配置 apache 下面的 config 里 httpd.conf 文件; 打开后找到 Directory 目录 里的AllowOverride None 改成 AllowOverride All 其次查找 虚拟机模块开启 vhost_alias_module 把#LoadModule vhost_alias_module modules/mod_vhost_alias.so 改成LoadModule vhost_alias_module modules/mod_vhost_alias.so 把前面#去掉 然后在 .htaccess 里加入这个 # Enable URL rewriting for pretty URLs RewriteEngine on RewriteRule !/.(js|ico|gif|jpg|JPG|GIF|PNG|png|css|log|html|shtml|xlsx|xml)$ index.php 创建好了你的第一个控制器和模板,你现在可以打开浏览器来访问看看了! 假设example.com是你的站点 域名,那么下面的URL都会带你访问你刚才创建的页面: http://example.com/ http://example.com/index http://example.com/index/index 恭喜你! 你已经准备好了,可以开始创建更多的控制器和Action!