简体   繁体   中英

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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