Heim  >  Artikel  >  Backend-Entwicklung  >  PHP伪静态页面函数附使用方法_PHP教程

PHP伪静态页面函数附使用方法_PHP教程

WBOY
WBOYOriginal
2016-07-21 15:51:56726Durchsuche

function MakeUrl($arr){ 
          foreach($arr as $key=>$value){ 
                  $url[]=$key."_".$value; 
                  } 
          $tmpurl=implode("_",$url); 
          return $tmpurl.".htm"; 
          } 
function ParseUrl(){ 
     if($_SERVER['PATH_INFO']!=""){ 
          $pathinfo=substr($_SERVER['PATH_INFO'],1); 
          $pathinfo=str_replace(".htm","",$pathinfo); 
          $path=explode("_",$pathinfo); 
          $count=count($path); 
          for($i=0;$i                  $_GET[$path[$i]]=$path[$i+1]; 
                  } 
                  } 
          } 
//使用实例,链接页面 
$path="http://www.***.com/blog.php/"; 
$path.=MakeUrl(array('BlogID'=>2,'page'=>1)); 
//浏览页面,调用函数ParseUrl();直接可以使用变量$_GET 

如果不想让别人知道你的网站使用PHP程序以达到安全的目的.你可以按照下面的方法配置你的httpd.conf文件
但这并不说明PHP不安全.
你可以使用下面的方法来达到隐藏的目的:
1.将PHP隐藏为其它语言
在你的httpd.conf里任意位置添加下面这一行 
# Make PHP code look like other code types
AddType application/x-httpd-php .asp .py .pl .jsp aspx
2.对 PHP 使用未知扩展名
在你的httpd.conf里任意位置添加下面这一行
# Make PHP code look like unknown types
AddType application/x-httpd-php .bop .foo .133t .los .abc
3.对 PHP 使用 HTML 扩展名
在你的httpd.conf里任意位置添加下面这一行
# Make all PHP code look like html
AddType application/x-httpd-php .htm .html 
重启你的apache.把你的PHP文件名改为上面你所设置的文件后缀名.打开测试吧... 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/319068.htmlTechArticlefunctionMakeUrl($arr){ foreach($arras$key=$value){ $url[]=$key."_".$value; } $tmpurl=implode("_",$url); return$tmpurl.".htm"; } functionParseUrl(){ if($_SERVER['PATH_INFO']!=""){ $p...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn