[英]Use same variable name in htaccess for rewriting PHP page
I have two pages index.php
and page_detail.php
, I'm using the following code in .htaccess
for rewriting: 我有两个页面
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]
URL rewriting is working good when I am on the index.php page. 当我在index.php页面上时,URL重写工作良好。 When as I move to
detail_page.php
then every href shows after page URL the following: 当我移到
detail_page.php
每个href在页面URL之后显示以下内容:
First page URL (good working): example.com/country/586/3.html
第一页网址(运作良好):
example.com/country/586/3.html
Trouble in: example.com/country/586/country/586/3.html
出现问题:
example.com/country/586/country/586/3.html
HTML link code: HTML链接代码:
<a href="<?=country_name($con,$row['country'])?>/<?=$row['country']?>/<?=$row['id']?>.html">
You either need to make the links look like this: 您要么需要使链接看起来像这样:
<a href="/<?=country_name($con,$row['country'])?>/<?=$row['country']?>/<?=$row['id']?>.html">
(note the leading /
) (注意开头
/
)
or add this to the header of your pages: 或将其添加到页面的标题中:
<base href="/" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.