一种就是伪静态方式,即用户和搜索引擎看到的是.html后缀的静态页面,但实际上它还是动态程序,只不过是通过某种方式进行了伪装。
这种方式也有两种实现方式:第一种是通过web服务器,进行url rewrite实现链接的静态化,下面以apache为例来说明一下其实现方式。对于有服务器配置权限的用户,推荐使用apache的mod_rewrite模块,这里假设已经安装好mod_rewrite模块,打开apache的配置文件,找到相应主机的部分,添加以下代码:
- rewriteengine on
- rewriterule ^/abc/([a-z]+)/([0-9]+).html$ /abc.php?action=$1&id=$2
然后在shell里执行service httpd reload,让apache重新载入配置就好了,但对于我们大多数人来讲,我们购买的只是空间,根本没有权限去修改apache的配置文件,那就没有办法了吗?不,当然有办法,首先我们进入到我们的空间的根目录下(如public_html),然后建立一个文件名为.htaccess的文件。这个文件内容基本如下:
- rewriteengine on
- rewritebase /
- rewriterule ^post/([0-9]+).htm read.php?1
- rewriterule ^post/([0-9]+)_([0-9]+).htm read.php?1&page=2
- rewriterule ^post/([0-9]+)_([0-9]+)_([0-9]+).htm read.php?1&page=2&=3
php程序写法
- function mod_rewrite(){
- if ( isset ( $_server [ ’ path_info ’ ])){
- $url = substr ( $_server [ ’ path_info ’ ] , 1 );
- $url = explode ( ’ / ’ , $url );
- foreach ( $url as $key => $value ){
- if ( $key % 2 != 1 ){
- if ( $value != ’’ ) $_get [ $value ] = $url [ $key + 1 ];
- $querystring [] = $value . ’ = ’ . $url [ $key + 1 ];
- }
- }
- $_server [ ’ query_string ’ ] = implode ( " & " , $querystring );
- $_server [ ’ php_self ’ ] = substr ( $_server [ ’ php_self ’ ]
- , 0 , strpos ( $_server [ ’ php_self ’ ] , ’ .php ’ ) + 4 );
- $_server [ ’ request_uri ’ ] = $_server [ ’ php_self ’ ]
- . ’ ? ’ . $_server [ ’ query_string ’ ];
- }
- }
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
波比源码 » PHP实现URL静态化
波比源码 » PHP实现URL静态化
cost levaquin 250mg levaquin 250mg price
buy avodart 0.5mg without prescription avodart 0.5mg sale buy ondansetron
buy aldactone 25mg pills fluconazole 200mg ca fluconazole 200mg uk
buy ampicillin 500mg generic buy acillin generic generic erythromycin 250mg
order sildenafil 50mg online order estradiol 2mg without prescription estrace 1mg for sale
brand tadalafil 10mg tadalis 10mg pills buy diclofenac
buy isotretinoin 10mg for sale isotretinoin 10mg uk buy zithromax 250mg for sale
acheter cialis cialis 40mg pour homme sildenafil 25mg pas cher
deltasone 20mg for sale buy deltasone 10mg sale buy sildenafil generic
buy modafinil 100mg online cheap order modafinil 100mg diamox 250mg canada
alendronate pill fosamax 70mg drug brand famotidine 20mg
purchase tacrolimus generic prograf 5mg cheap ursodiol ca
buy isosorbide 20mg for sale order isosorbide 40mg pill buy telmisartan generic
bupropion 150 mg brand atomoxetine price quetiapine 100mg usa
molnunat 200 mg generic cefdinir online buy lansoprazole for sale
cialis 5mg Real cialis online buy sildenafil tablets
buy revia online cheap order naltrexone for sale buy generic aripiprazole 30mg
order avlosulfon 100 mg generic buy dapsone 100 mg online aceon ca
provera 10mg for sale microzide 25 mg brand order periactin 4 mg pills
buy isotretinoin 20mg generic accutane 10mg cost prednisone 20mg generic
order piracetam 800 mg pill order viagra sale oral viagra 50mg
purchase azithromycin for sale cost prednisolone buy neurontin 100mg
tadalafil 10mg drug cheap anafranil 50mg clomipramine 25mg generic
buy aralen online baricitinib price olumiant 2mg cheap
metformin drug glycomet 1000mg pills cialis 40mg usa
zyprexa 10mg usa buy nebivolol 20mg pills cheap diovan 80mg
clozapine 50mg brand buy clozaril pills decadron 0,5 mg uk
viagra australia order lisinopril 10mg pills order lisinopril 10mg online cheap
order prilosec 20mg pills buy omeprazole 10mg sale poker online free
metoprolol generic buy metoprolol 100mg pills order levitra 20mg generic
essays help websites to write essays empire city casino online
order vardenafil 20mg pill levitra 10mg cost medrol 16mg for sale
cialis 10mg us tadalafil 20mg over the counter sildenafil pharmacy
dapoxetine 30mg tablet dapoxetine drug synthroid tablet
buy generic cialis 40mg usa viagra overnight order viagra 100mg without prescription
methotrexate 10mg brand order methotrexate 2.5mg pill oral metoclopramide
buy sumatriptan pills avodart 0.5mg uk order avodart 0.5mg sale
buy tamsulosin 0.2mg pill flomax 0.4mg oral order spironolactone 25mg online
cialis usa order ciprofloxacin online cheap ciprofloxacin 500mg tablet
order simvastatin 10mg online purchase finasteride generic purchase finasteride pills
order diflucan 100mg for sale buy generic viagra 100mg purchase viagra online
order keflex 125mg generic purchase cleocin without prescription buy erythromycin pills
order viagra 100mg pill order viagra 50mg generic generic cialis 40mg
buy ceftin 500mg generic buy bimatoprost pill order methocarbamol 500mg sale