简体   繁体   English

为什么我的htaccess将当前页面的URL添加到页面上的所有链接

[英]why is my htaccess adding current page url to all links on the page

Am new to htaccess rewrite rules but with some few tutorials i've been able to write some few rules but the problem now is that the rules work well but every links on the page is preceded with the current page link therefore rendering all links on the page invalid. htaccess重写规则是新手,但是通过一些教程,我已经能够编写一些规则,但是现在的问题是,规则很好用,但是页面上的每个链接都以当前页面链接开头,因此呈现了所有链接。页面无效。 Below is a sample code 以下是示例代码

RewriteEngine on
RewriteRule ^school/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ school.php?country=$1&school=$2 [NC,L] 

For example if i access school page as school/spain/university the link to my index page which is supposed to be index would change to school/spain/universty/index 例如,如果我以学校/西班牙/大学的身份访问学校页面,则指向应该是索引的索引页面的链接将更改为学校/西班牙/大学/索引

I've searched everywhere for a similar problem or solution but i didn't see any. 我到处都在寻找类似的问题或解决方案,但没有发现任何问题。

The best way to solve the problem is to use base link at the head of your page. 解决问题的最佳方法是使用页面顶部的基本链接。

This solves the problem perfectly, it doesn't matter if you're using relative link or absolute link. 这可以完美地解决问题,无论您使用相对链接还是绝对链接都没有关系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM