razorsese Posted December 26, 2012 Share Posted December 26, 2012 So i got the following url format localhost:8080/test now i have 1 link named LI if i click on it it becomes: http://localhost:8080/TST/il and in it i have a list of links if i click on one of them it becomes: http://localhost:8080/TST/item/view/19 but now if I want to go back to that list if i click on LI it dosen't go back to http://localhost:8080/TST/il but instead it go to http://localhost:8080/TST/item/view/il the html code for the link is the following <a href="il">LI</a> and my .htaccess is the following : RewriteRule ^([a-zA-Z]*)/?([a-zA-Z]*)?/?([a-zA-Z0-9]*)?/?$ index.php?controller=$1&action=$2&id=$3 [NC] Quote Link to comment https://forums.phpfreaks.com/topic/272372-php-link-problem/ Share on other sites More sharing options...
DavidAM Posted December 27, 2012 Share Posted December 27, 2012 You are using a "relative" path in the link. So the browser is building the absolute url by appending the relative part that you specified to the path of the current page. As far as the browser knows, it is looking at a page at http ://localhost:8080/TST/item/view/19 -- filename: 19, path: /TST/item/view -- so it ends up with /TST/item/view/il. When using mod_rewrite, it is easier (IMO) to always specify full paths (although you can leave the domain part out): <A href="/TST/il">LI</A> Quote Link to comment https://forums.phpfreaks.com/topic/272372-php-link-problem/#findComment-1401448 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.