网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 服务器与数据库 > 服务器环境搭建
User Name
Password
 
FAQ Members List Calendar Cheap Glasses Mark Forums Read

服务器环境搭建 Windows,Linux,IIS,Apache等服务器配置、安全维护以及PHP和MYSQL运行环境讨论。

Reply
 
Thread Tools Display Modes
  #1   IP: 82.116.154.18
Old 2009-01-05, 04:51 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default Php伪静态页问题!

果用PHP生成HTML那就难更新!

生成伪静态的话,用Apache的MOD Rewrite方法不太可靠,因为服务器不是我的,大多数服务器是别人的。有可能开有可能不开。

有可能 是LINUX也有可能是WIND。

那么我只有用别的方法找到了一个方法,来自互联网;
Code:
function mod_rewrite(){
     global $_GET;
     $nav=$_SERVER["REQUEST_URI"];
     $script_name=$_SERVER["SCRIPT_NAME"];
     $nav=substr(ereg_replace("^$script_name","",urldecode($nav)),1);
     $nav=preg_replace("/^.ht(m){1}(l){0,1}$/","",$nav);//这句是去掉尾部的.html或.htm
     $vars = explode("/",$nav);
     for($i=0;$i<Count($vars);$i+=2){
          $_GET["$vars[$i]"]=$vars[$i+1];
     }
     return $_GET;
}
我能看明白,但是我不知道如何调用!

比如讲我的网址:www.xxx.com/index.php

以上是首页,那么我访问www.xxx.com/xx-xx-xx.html这个时候没有 这个页面就会出错或者转向404页!

郁闷!我有点笨,不知道怎么写了。如果是:

www.xxx.com/index.php?xx-xx-xx.html这就太明显了!

请问有没有人做过?给个例子!谢谢!
Reply With Quote
  #2   IP: 82.116.154.18
Old 2009-01-05, 04:52 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default

Code:
<?php
function mod_rewrite(){
     global $_GET;
     //$nav=$_SERVER["REQUEST_URI"];
     $nav = '/129244/index.html';
     //$script_name=$_SERVER["SCRIPT_NAME"];
     $script_name = '/index.html';
     $nav=substr(ereg_replace("^$script_name","",urldecode($nav)),1);
     $nav=preg_replace("/^.ht(m){1}(l){0,1}$/","",$nav);//这句是去掉尾部的.html或.htm
     $vars = explode("/",$nav);
     for($i=0;$i<Count($vars);$i+=2){
          $_GET["$vars[$i]"]=$vars[$i+1];
     }
     return $_GET;
}
$aa = mod_rewrite();
var_dump($aa);
echo '<br>';
var_dump($_SERVER["REQUEST_URI"]);
?>
这样看就明白了
发的那个函数只是对请求的url进行了分解,具体的操作还需要你根据你的url情况自己解决
Reply With Quote
  #3   IP: 82.116.154.18
Old 2009-01-05, 04:53 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default

Code:
RewriteEngine On

# Rewrite requests for sitemap.xml

RewriteRule ^zzxj/sitemap.xml$ /zzxj/sitemap.php?target=google [L]

# Rewrite requests for urllist.txt
RewriteRule ^zzxj/urllist.txt$ /zzxj/sitemap.php?target=yahoo [L]
面的放在.htaccess里的,.htaccess放根目录
重写zzxj/sitemap.xml 至PHP程序
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 02:00 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.