【发布时间】:2015-02-26 10:46:42
【问题描述】:
我有两个页面index.php 和page_detail.php,我在.htaccess 中使用以下代码进行重写:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)\.html$ /page_detail.php?cat=$1&title=$2&pageId=$3&id=$4 [L]
RewriteBase /
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /page_detail.php?countryname=$1&country=$2&id=$3 [L]
当我在 index.php 页面上时,URL 重写工作得很好。当我移至 detail_page.php 时,每个 href 在页面 URL 之后显示以下内容:
首页网址(运行良好):example.com/country/586/3.html
问题:example.com/country/586/country/586/3.html
HTML链接代码:
<a href="<?=country_name($con,$row['country'])?>/<?=$row['country']?>/<?=$row['id']?>.html">
【问题讨论】:
-
我认为这也与 HTML/PHP 代码中的路径有关,能否请您将代码发布到 href 链接所在的位置?
-
实际上,它删除了最后一个参数值并将其视为baseurl并抛出url
-
最好在链接中使用绝对 URL。