-
頁面靜態(tài)化查看全部
-
動態(tài)URL地址設(shè)置靜態(tài)形式查看全部
-
WEB服務(wù)器rewrite配置以及案例 nginx下rewrite配置 rewrite ^/detail/(\d+)\.html$ /detail.php?id=$1 last; 1、通過xshell連接虛擬機(jī) cd /etc/nginx/conf.d sudo vim static.singwa.com.conf 在server->location->if語句里插入下面這段代碼: rewrite ^/detail/(\d+)\.shtml$ /detail.php?id=$1 last; 2、編寫detail.php代碼 cd /data/static/ sudo vim detail.php <?php echo "nginx: this id is ".$_GET['id']; 3、重啟nginx服務(wù)器 sudo service nginx restart查看全部
-
如果在項目根目錄下面有個detail目錄,并且目錄里有個178.html文件。 那么static.com/detail/178.html會去加載純靜態(tài)頁面178.html,還是會去加載detail.php的動態(tài)內(nèi)容呢? 在static目錄下新建一個detail目錄,再新建一個178.html(this is a static page)文件。 刷新static.com/detail/178.html,頁面加載的還是detail.php的動態(tài)內(nèi)容。 那么,如何設(shè)置成如果有178.html靜態(tài)頁面就去加載它?,如果沒有就去加載配置的偽靜態(tài)的內(nèi)容? 在Apache2.4.4\conf\extra目錄下配置httpd-vhosts.conf 在<VirtualHost 127.0.0.13:80>中加入以下兩句代碼 RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f DOCUMENT_ROOT:代表項目的根目錄;REQUEST_FILENAME:代表所請求的內(nèi)容(detail/178.html);d:代表目錄;f:代表文件; 這兩句話的意思代表:當(dāng)服務(wù)器存在這個目錄或文件,那么就去訪問這個存在的目錄或文件查看全部
-
偽靜態(tài)配置案例 在Apache2.4.4\conf\extra目錄下配置httpd-vhosts.conf 在<VirtualHost 127.0.0.13:80>中加入以下兩句代碼 RewriteEngine on RewriteRule ^/detail/([0-9]*).html$ /detail.php?id=$1 static下新建一個detail.php文件 <?php echo "this news id is ".$_GET['id']; 在瀏覽器地址欄輸入:http://static.com/detail/178.html(看上去像純靜態(tài)化的地址,實際上加載的內(nèi)容是動態(tài)的) 會打印出:this news id is 178查看全部
-
1、虛擬域名配置 1.1、在httpd.conf文件中開啟相關(guān)模式 開啟mod_rewrite.so(用phpinfo()查看是否開啟) LoadModule rewrite_module modules/mod_rewrite.so 開啟# Virtual hosts下的httpd-vhosts.conf Include conf/extra/httpd-vhosts.conf 1.2、在Apache2.4.4\conf\extra目錄下配置httpd-vhosts.conf <VirtualHost 127.0.0.13:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "C:\wamp\www\mooc\static" ServerName static.com ServerAlias www.dummy-host.example.com ErrorLog "logs/dummy-host.example.com-error.log" CustomLog "logs/dummy-host.example.com-access.log" common </VirtualHost> 1.3、配置C盤C:\WINDOWS\system32\drivers\etc下的hosts文件(IP 域名) 127.0.0.13 static.com查看全部
-
apache下rewrite配置 1、虛擬域名配置 2、http_vhosts_conf配置文件配置相關(guān)信息查看全部
-
WEB服務(wù)器rewrite配置以及案例(在服務(wù)器當(dāng)中做一些配置也可以達(dá)到偽靜態(tài)的目的) Apache下rewrite配置 Nginx下rewrite配置查看全部
-
<?php /* 通過正則表達(dá)式去分析偽靜態(tài)URL地址 http://localhost/mooc/static/newsList.php?type=2&category_id=1 http://localhost/mooc/static/newsList.php/2/1.html 2=>type=2 | 1=>category_id=1 */ //打印服務(wù)器當(dāng)中的SERVER變量(里面有一個[PATH_INFO] => /2/1.html) //print_r($_SERVER); // /2/1.html if(preg_match('/^\/(\d+)\/(\d+).html/',$_SERVER['PATH_INFO'],$arr)){ //print_r($arr); $type = $arr[1]; $category_id = $arr[2]; //提取到$type和$category_id的值之后,就可以寫sql語句獲取到數(shù)據(jù)表的數(shù)據(jù),然后把數(shù)據(jù)組裝好放到模板里去 }else{ //TODO匹配不到的話根據(jù)業(yè)務(wù)需求做相應(yīng)的處理 }查看全部
-
<?php /* 通過正則表達(dá)式去分析偽靜態(tài)URL地址 http://localhost/mooc/static/newsList.php?type=2&category_id=1 http://localhost/mooc/static/newsList.php/2/1.html 2=>type=2 | 1=>category_id=1 */ //打印服務(wù)器當(dāng)中的SERVER變量(里面有一個[PATH_INFO] => /2/1.html) print_r($_SERVER);查看全部
-
PHP處理偽靜態(tài) 偽靜態(tài)(其實就是把動態(tài)的URL地址轉(zhuǎn)換為類似靜態(tài)的URL地址,實際上還是動態(tài)頁面) 設(shè)置成偽靜態(tài)其實還是為了:1、讓URL地址美觀 2、讓百度、Google等等搜索引擎收錄我們的內(nèi)容 通過正則表達(dá)式去分析偽靜態(tài)url地址 案例分析(path_info模式)print_r($_SERVER); /newsList.php/2/1.html nginx服務(wù)器默認(rèn)情況下不支持path_info模式,需要配置查看全部
-
$.each() 遍歷指定元素 或者 數(shù)組對象 $(seletor).each(function(key,value)) $.each(retult.data,function(key,value)) == foreach($data as $key=>$value) hot.js $.ajax({ url:'http://localhost/mooc/static/api/hot.php', type:'get', dataType:'json', error:function(){ }, success:function(result){ if(result.code==1){ html = ''; //遍歷result對象中的data數(shù)據(jù) $.each(result.data,function(key,value){ html += '<li><a href="/">'+value.title+'</a></li>'; }); $("#hot_html").html(html); }else{ //todo根據(jù)業(yè)務(wù)需求來處理 } }, }); temp.php <div id="hot"> <p>今日排行榜:</p> <ul id="hot_html"> </ul> </div> index2.php indexhot.php查看全部
-
講的不錯啊,清晰明了查看全部
-
配置文件: RewriteEngine on RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f RewriteRule ^/detail/([0-9]*).html$ /detail.php?id=$1查看全部
-
nginx服務(wù)器不支持PATH_INFO:模式查看全部
舉報
0/150
提交
取消