2

I have the link: www.mysite.com/jobs/stackoverflow

And I want to get this link using a relative file path: www.mysite.com/jobs/stackoverflow/123

Right now I am getting the current url using PHP and then appending '/123' onto the end of the 'href' value to access the subfolder. This method works but I was wondering if there is a way to write a relative link that will link to a subfolder. At first I thought it would be as easy as typing:

<a href="123">Link</a>

but that replaces the 'stackoverflow' part rather than appending it onto the end.

I'm fine with using the PHP solution and I am not looking for a javascript or jQuery solution, I was just curious to see if there was a simple way to do this using only HTML.

G-SCO
  • 121
  • 3
  • 11
  • you can use htaccess rewriting, this allows you to setup rules for urls. so what you could do in the end is have href="/123" and setup a rule so that this type of url maps to www.mysite.com/jobs/stackoverflow/123 Look at this link: https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/ – floor Apr 06 '15 at 21:45
  • or create a "router" in php. Similar to my above comment. Only using php to break apart the url or determine where the page should actually go. – floor Apr 06 '15 at 21:47
  • or pending on your file structure. Relative pathing can done with ./123 where the ./ means the rest of the directory path that this file or path is located. – floor Apr 06 '15 at 21:49

1 Answers1

-1

I found someone linking to the current directory like this:

Basic HTML - how to set relative path to current folder?

so putting the ./ before the 123 in your link might work.

Community
  • 1
  • 1
Jens Ackou
  • 151
  • 11