且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用PHP创建动态/友好的URL?

更新时间:2022-11-26 13:07:23

如果您只有cpanel使用 .htaccess



如果这不起作用,你就会得到解析php中的url具有如下链接:



http://server.com/router.php/search



你可以这样做。

   list($ junk,$ url)= explode(router.php,$ _ SERVER ['REQUEST_URI']); 
$ paths = explode(/,$ url);
if($ paths [0] =='search')
{
标题(位置:/search.php);
}
?>


Can anyone explain how to create friendly URLs? I mean URLs like http://store.steampowered.com/app/22600/ that doesn't have any pages like index.php visible.

If you only have cpanel use .htaccess.

If that doesn't work, you are left with parsing the url in php with a link like this:

http://server.com/router.php/search

You can do that with something like this.

<?
list($junk,$url) = explode("router.php",$_SERVER['REQUEST_URI']);
$paths = explode("/", $url);
if ($paths[0] == 'search')
{
   Header("Location: /search.php");
}
?>