標籤:
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>
apache設定檔
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "d:/wnmp/web/myproject"
ServerName www.key.local
<Directory "d:/wnmp/web/myproject"> // 這裡是項目的目錄
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
NGINX裡這樣配置
location / {
root D:/wnmp/web/myproject/;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?$1 last;
break;
}
}
CI架構apache和nginx環境下面統一去掉路徑URL後面的index.php