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

來源:互聯網
上載者:User

標籤:

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.