.htaccess文件配置
1 <IfModule mod_rewrite.c> 2 RewriteEngine On 3 RewriteBase / 4 RewriteCond $1 !^(index\.php|assets|system|robots\.txt) 5 RewriteRule ^(.*)$ /index.php/$1 [L,QSA] 6 7 </IfModule>
簡要說明:關鍵是這句:rewirteCond ,assets是目錄。
apache的配置:
1 <VirtualHost *:80> 2 ServerAdmin jjj@163.com 3 DocumentRoot "d:/mywork/m" 4 5 ServerName m.mimi.com 6 7 <Directory "d:/mywork/m"> // 這里是項目的目錄 8 Options Indexes MultiViews FollowSymLinks 9 AllowOverride All 10 Order allow,deny 11 allow from all 12 </Directory> 13 </VirtualHost>
簡要說明:
ServerAdmin表示錯誤信息地址,如果發生錯誤發送到這個郵箱地址。
Indexes 的作用就是當該目錄下沒有 index.html 文件時,就顯示目錄結構,去掉 Indexes,Apache 就不會顯示該目錄的列表了。
Nginx配置幾句
1 location / 2 { 3 index index.php; 4 if (!-e $request_filename) { 5 rewrite ^/(.*)$ /index.php?$1 last; 6 break; 7 } 8 }