CI框架apache和nginx環境下面統一去掉路徑URL後面的index.php

APACHE: php

在apache下去掉url上的index.php折騰了很久 ,一直是訪問css ,js,圖片文件   you can't access files on server 之類的錯誤提示,apached的配置上說的是 css

把 AllowOverride  none 改爲  AllowOverride All ,而後allow from all,一直不生效,能夠跳轉頁面,可是樣式,js文件,圖片都丟失, html

發現仍是.htaccss的RewriteCond出現了問題,原來是目錄不對。 web

原先的樣式文件,圖片文件,js文件都放在application/views/templates下面了,後來改爲一個和application同級的assets下面,如圖: apache


而後.htaccess文件裏這樣寫


<IfModule mod_rewrite.c>  app

RewriteEngine On   ide

RewriteBase /   url

RewriteCond $1 !^(index\.php|assets|system|robots\.txt)     spa

RewriteRule ^(.*)$ /index.php/$1 [L,QSA]      server

</IfModule>  

apache配置文件

<VirtualHost *:80>  
    ServerAdmin major2000@sina.com  
    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;      }   }

相關文章
相關標籤/搜索