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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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