gpt4 book ai didi

php - 网站没有正确重定向

转载 作者:搜寻专家 更新时间:2023-10-31 21:28:56 25 4
gpt4 key购买 nike

我正在创建一个 strawpoll 网站(有点像 strawpoll.me 但你可以将投票设置为过期并且它使用 cookie),可以在 http://www.makepoll.co.uk 找到。 .

问题是,当您访问它时,我们会跳转到 http://www.makepoll.co.uk/1什么时候应该带你到http://www.makepoll.co.uk/home .

我的 htaccess 文件如下所示:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^([a-z]+)/?$ index.php?p=$1 [L,QSA]
RewriteRule ^([a-z]+)/([A-Z0-9]+)/?$ index.php?p=$1&s=$2 [L,QSA]
</IfModule>

我的 index.php 页面如下所示:

<?php require("backend/index.php");
if(empty($page)==TRUE)
{
header("Location: home");
die();
}
?><!DOCTYPE html>
<html>
<head>
<?php if(empty($part)==FALSE)
{
echo "<link rel=\"stylesheet\" href=\"../frontend/jquery-ui.css\">\n";
echo "<link rel=\"stylesheet\" href=\"../frontend/styles.css\">\n";
echo "<script src=\"../frontend/jquery.js\"></script>\n";
echo "<script src=\"../frontend/jquery-ui.js\"></script>\n";
}
else
{
echo "<link rel=\"stylesheet\" href=\"frontend/jquery-ui.css\">\n";
echo "<link rel=\"stylesheet\" href=\"frontend/styles.css\">\n";
echo "<script src=\"frontend/jquery.js\"></script>\n";
echo "<script src=\"frontend/jquery-ui.js\"></script>\n";
}
?>
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
</head>
<body>
<?php if(empty($part)==FALSE)
{
echo "<a href=\"#content\" tabindex=\"", $tab++, "\"><img src=\"../frontend/content.png\" alt=\"Skip to Content\"></a>\n";
}
else
{
echo "<a href=\"#content\" tabindex=\"", $tab++, "\"><img src=\"frontend/content.png\" alt=\"Skip to Content\"></a>\n";
}
?>
<div id="pollbox">
<?php if(in_array("{$page}.php", $content)==TRUE)
{
include("{$basedir}/content/{$page}.php");
}
else
{
echo "<p>Page not found, I'm sorry</p>";
http_response_code(404);
}
?>
</div>
<footer>
<ul>
<li><a href="../home/1" tabindex="<?php echo $tab++; ?>">Create New Poll</a></li>
<li><a href="../terms/1" tabindex="<?php echo $tab++; ?>">Terms of Service</a></li>
<li><a href="../terms/2" tabindex="<?php echo $tab++; ?>">Privacy Policy</a></li>
<li>Contact Us</li>
</ul>
</footer>
</body>
</html>

backend/index.php 页面如下所示:

<?php /* This file will contain the backend functions and set things up, such as the MySQL connection, and set the variables the site is going to use. This file line will connect to the SQL database. If there is a connection error, the script will be killed, and since there is no point continuing, a message will be displayed */
ob_start();

session_start();
$connection = new mysqli("localhost", "root", "", "example");
if($connection->connect_error)
{
die("Sorry... I was unable to connect");
}
$basedir = dirname(__FILE__); // This variable will hold the path to the current folder
$page = strtolower($_GET["p"]); // This variable will hold the current page name
$part = $_GET["s"]; // This variable will keep track of which part of the script the user is on
$tab = 1; // This variable will hold the tabindex
$content = scandir("{$basedir}\content"); // This will scan the content folder and return an array
unset($content[0], $content[1]); // This will unset the 0th and 1st element of the array
include("{$basedir}/functions.php"); // This will include the backend functions script
?>

大佬们可以指点一下吗?就我而言,它应该重定向到/home

最佳答案

将此重写规则添加到列表中

RewriteRule ^([a-z]+)/home$ index.php?p=$1 [L,QSA]

希望对你有帮助

关于php - 网站没有正确重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32409049/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com