gpt4 book ai didi

php - 将页面 URL 更改为 PHP

转载 作者:行者123 更新时间:2023-12-02 04:43:38 25 4
gpt4 key购买 nike

您好,我想将页面 URL 转换为 www.example.com/pictures.php?title=yyoy类似于 www.example.com/page/yoyo.php

我该怎么做?

www.example.com/pictures.php?title=yyoy这些页面是在有人将图片上传到我的网站时生成的,因此我想将这些类型的 URL 转换为如上所示的示例。

因为这些页面不能被搜索引擎收录。谢谢

Picture.php

<?php 
include("connection.php");

if(isset($_GET['title'])){

$page_id = $_GET['title'];

$select_query = "select * from save_data where Title='$page_id'";

$run_query = mysql_query($select_query);

while($row=mysql_fetch_array($run_query)){

$post_id = $row['ID'];
$post_title = $row['Title'];
$post_image = $row['Name'];

$page_title = $_GET['title'];
header('uploads/ ' . $page_title . '.php')

?>
<center>
<h2>
<a href="pictures.php?title=<?php echo $post_title; ?>">

<?php echo $post_title; ?>

</a></center>

</h2>

<center><img src="uploads/<?php echo $post_image; ?>" /></center>


<?php } }?>

最佳答案

我没有对此进行测试,但您应该在 .htaccess 文件中使用类似于以下的规则:

RewriteEngine on
RewriteRule ^pictures.php?title=(.+)$ page/$1.php [R]

请注意,您需要启用 mod_rewrite 才能在 apache2

中使用

关于php - 将页面 URL 更改为 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20273601/

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