任何人都可以帮助使用htaccess重写URL

问题描述 投票:-1回答:1

我在使用.htaccess重写URL时遇到了一些麻烦,这是我使用的htaccess代码

RewriteRule "^([ \w-]+)/?$" /future/topic?post=$1&title=$2 [L,NC,QSA]

但是它不起作用

http://localhost/future/topic?post=2028&recipes-from-chef-bobby-flay-comfort-food-for-discomfiting-times

和URL代码:

 <?php   echo ("<p><a href='topic?post=$id&" . $slug .  "'>" . $title . "</a>");   ?>
php regex .htaccess
1个回答
0
投票

您没有传递htaccess中定义的两个参数。您的标题参数丢失。

通过执行此操作纠正

<?php   

echo "<p><a href='topic?post=$id&title=$slug'>$title</a>";
//when using double quotes a lot of things can be based directly mostly variables

 ?>

希望这会有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.