去掉前面的#
LoadModule rewrite_module modules/mod_rewrite.so
对于Ubuntu,须要在apache安装目录下的 mods-enabled 文件夹中建立软链接。php
进入 /mods-enabled 下,apache
cd mods-enabled/
sudo ln -s ../mods-available/rewrite.load rewrite.load # 要确保 ../mods-available/rewrite.load 文件存在,不存在须要安装rewrite模块
注:apache安装目录下:mods-available---未启用的模块,mods-enabled----已启用的模块ubuntu
能够在apache的配置文件 conf/httpd.conf 末尾添加以下代码,或是在 sites-enabled 文件夹下新建个 .conf 文件,文件名随意,也可像 mods-enabled/ 下那样建立连接。app
Alias /athena "/home/liuqian/workspace/athena/" # 依据实际状况改成本身的路径 <Directory "/home/liuqian/workspace/athena/"> # 依据实际状况改成本身的路径 Options Indexes MultiViews FollowSymLinks AllowOverride All # 主要是这个 Order allow,deny Allow from all </Directory>
注:apache安装目录下:sites-available---未加载的配置文件,sites-enabled----已加载的配置文件ide
进入到项目文件夹下,在 index.php 所在的目录下建立 .htaccess 文件网站
文件中写以下:spa
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|BJUI|captcha|js|plugins|images|robots\.txt) # index.php的同级目录下还有要过滤除去的文件夹,把名字一并写到这里 RewriteRule ^(.*)$ /athena/index.php/$1 [L] # 若是网站就在根目录下,就直接写 index.php/$1 [L],个人index.php是在根目录下的athena文件下中
#若是没有安装mod_rewrite模块,全部的404页面都将被 #发送到index.php,此时,程序会像没有设置隐藏时同样运行 ErrorDocument 404 index.php
$config['index_page'] = "index.php";
改成:rest
$config['index_page'] = "";
sudo apachectl restart # 这里是ubuntu的重启命令