Jump to content

Php Link Problem


razorsese

Recommended Posts

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]

Link to comment
https://forums.phpfreaks.com/topic/272372-php-link-problem/
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/272372-php-link-problem/#findComment-1401448
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.