apache
在apache下去掉url上的index.php折腾了好久 ,一直是访问css ,js,图片文件 you can't access files on server 之类的错误提示,apached的配置上说的是
把 AllowOverride none 改成 AllowOverride All ,然后allow from all,一直不生效,可以跳转页面,但是样式,js文件,图片都丢失,
发现还是.htaccss的RewriteCond出现了问题,原来是目录不对。
原先的样式文件,图片文件,js文件都放在application/views/templates下面了,后来改成一个和application同级的assets下面,如图:
然后.htaccess是下面的这个样子:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond $1 !^(index\.php|assets|system|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
</IfModule>
关键是这句:rewirteCond ,assets是目录。
附上 apache的配置:
<VirtualHost *:80>
ServerAdmin vimi@163.com
DocumentRoot "d:/mywork/m"
ServerName m.vimi.com
<Directory "d:/mywork/m"> // 这里是项目的目录
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
nginx
nginx很简单,如下:
location /
{
index index.php;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?$1 last;
break;
}
}