【发布时间】:2014-10-26 21:42:35
【问题描述】:
我想显示我的页面网址:
www.mypage.com/?q=picture
代替:
www.mypage.com/picture.html
我不知道如何重定向我想查看的页面。但网址不应显示页面扩展名 我已经尝试过这样的事情,但它不起作用:
<a href="?q=home" style="text-decoration: none; color: #1E90FF; font-size:25px;">Home</a>
<?php
if(isset($_GET['q']) && $_GET['q']!="" )
{
$ext=".php";
$page=$_GET['q'].$ext;
if(file_exists($page))
{
header('location:$page');
}
else
{
header('location:errorpage.php');
}
}
?>
【问题讨论】:
-
你的代码与
.htaccess无关,我想你在找mod_rewritehttpd.apache.org/docs/current/mod/mod_rewrite.html -
我不是在寻找任何 mod_rewrite.. 我只是想使用我的代码,但是当我尝试我的代码时,它并没有重定向我想要的页面。就是这样
-
尝试将 $ext 更改为 ".html"