如何使用PHP创建动态/友好的URL? [英] How to create dynamic/friendly URLs using PHP?

查看:166
本文介绍了如何使用PHP创建动态/友好的URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以解释如何创建友好的网址?我的意思是像 http://store.steampowered.com/app/22600/ 这样的网址,没有像 index.php 可见

解决方案

如果您只有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");
}
?>

这篇关于如何使用PHP创建动态/友好的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆