久久调教,免费看黄色影片,www五月,国产精品免费一区二区区,亚洲欧美日韩综合一区,亚洲欧美日韩精品在线,2021免费日韩视频网

龍巖易富通網(wǎng)絡(luò)科技有限公司

龍巖小程序開發(fā),龍巖分銷系統(tǒng)

在nginx和apache下如何去除url中的index.php

2015.10.01 | 1897閱讀 | 0條評論 | 服務(wù)器配置

apache環(huán)境下:

通過 .htaccess 文件來設(shè)置一些簡單的規(guī)則刪除它。

<IfModule mod_rewrite.c> 

 Options +FollowSymlinks -Multiviews 

 RewriteEngine on 

 RewriteCond %{REQUEST_FILENAME} !-d 

 RewriteCond %{REQUEST_FILENAME} !-f 

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

 RewriteRule /api/(.*)$ /api/index.php/$1 

 RewriteRule /sysadmin/(.*)$ /sysadmin/index.php/$1 

</IfModule>

如果你的項目不在根目錄請把上面這一句改為:RewriteRule ^(.*)$ index.php/$1 [L]

在上面的例子中,可以實現(xiàn)任何非 index.php、images 和 robots.txt 的 HTTP 請求都被指向 index.php。


Nginx環(huán)境下:

修改nginx配置文件,在SERVER段中添加如下代碼:

location / {   

 if (-f $request_filename) {      

            expires max; 

            break;     

  }     

  if (!-e $request_filename) {         

            rewrite ^/(.*)$ /index.php?/$1 last;     

  } 

}


location /目錄/ {

    if (!-e $request_filename){

   rewrite ^/目錄/(.*)$ /目錄/index.php/$1 last;

    }

}

贊 (

發(fā)表評論