久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php如何實(shí)現(xiàn)頁面路由轉(zhuǎn)發(fā)

      php實(shí)現(xiàn)頁面路由轉(zhuǎn)發(fā)的方法:首先配置nginx服務(wù)器,在【.htaccess】中寫上nginx的語法;然后打開根目錄的【index.php】,編寫文件路由即可。

      php如何實(shí)現(xiàn)頁面路由轉(zhuǎn)發(fā)

      php實(shí)現(xiàn)頁面路由轉(zhuǎn)發(fā)的方法:

      1、配置nginx服務(wù)器

      nginx服務(wù)器不會自動讀取.htaccess,也不支持.htaccess語法,這里需要做一個投機(jī)取巧的方法:在.htaccess中寫上nginx的語法,同時把該文件引入到nginx的配置中。這樣就達(dá)到了和apache同樣的目的。編輯.htaccess文件,輸入以下內(nèi)容并保存

      if (!-e $request_filename){     rewrite ^(.*)$ /index.php; } location ~ /.ht {     deny  all; }

      【解釋】nginx匹配失敗的uri全都轉(zhuǎn)給index.php,同時禁止訪問.htaccess文件

      最重要的一步:在nginx配置中,在server{}內(nèi)加入一句話:

      include E:/demo/.htaccess;

      【解釋】將該文件原封不動的引入到nginx配置中。注意使用絕對路徑!

      2、編寫index.php路由

      打開根目錄的index.php,輸入以下內(nèi)容

      <?php     //路由     $uri = $_SERVER['REQUEST_URI']; //獲取uri,例如 http://www.abc.com/study,其uri="/study"     switch($uri){         case "/":      include "template/home.php";  break;         case "/study": include "template/study.php"; break;         case "/play":  include "template/play.php";  break;     } 編寫/template/下的網(wǎng)頁文件 /template/下存放的網(wǎng)頁文件,隨便編輯點(diǎn)html用于測試。例如 home.php <!DOCTYPE html> <html> <head>     <meta charset="utf-8">     <title>這里是home</title> </head> <body>     <h1>你好,這里是home頁面</h1> </body> </html>

      效果

      在瀏覽器訪問http://localhost:8000 可以訪問到/template/home.php

      在瀏覽器訪問http://localhost:8000/study 可以訪問到/template/study.php

      在瀏覽器訪問http://localhost:8000/play 可以訪問到/template/play.php

      相關(guān)免費(fèi)學(xué)習(xí)推薦:php編程(視頻)

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號