去掉 public
将 public 里的 index.php 移动到根目录,并修改内容如下:
<?php// 定义应用目录define('APP_PATH', __DIR__ . '/application/'); //目录不一样define('SITE_URL','http://xxx.com');// 加载框架引导文件require __DIR__ . '/thinkphp/start.php';
做到这一步,我们即可隐藏 public 目录。
去掉 index.php
在 APACHE (phpstudy) 里面去配置
1.将 httpd.conf 配置文件中加载 mod_rewrite.so 模块
#LoadModule rewrite_module modules/mod_rewrite.so把前面的警号去掉
2.在 APACHE (phpstudy) 里面去配置(有多处)
将 AllowOverride None 中的 None 改为 All
<Directory "D:/server/apache/cgi-bin"> AllowOverride none改为 AllowOverride ALLOptions NoneOrder allow,denyAllow from all</Directory>
3.在根目录下创建 .htaccess 文件
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1] 这句话表示将 index.php 隐藏掉的,如果不想省略就可以将这句话去掉。(public 下也有这个文件)
<IfModule mod_rewrite.c>Options +FollowSymlinks -MultiviewsRewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]</IfModule>
补充:在 windows 下不能建立以点开头的文件,你可以先随便建立一个文件
然后在 DOS 在操作 rename xx.xx .htaccess