skip to Main Content

I am building a html/css/js website. In local code, I have set links as <a href="about.html"> which opens the corresponding page properly.
I will have to deploy this website on an apache server using a ftp client. The domain is already configured and I wanted to know if the same tags will work properly after deployment or will I have to change them to something like <a href="mydomain.com/about.html">?

3

Answers


  1. If your index.html and about.html are in the same directory – it will work the same

    Login or Signup to reply.
  2. As long as you keep the same folder structure when you upload your project to the server, they will keep working. You don’t have to add the domain in front.

    Login or Signup to reply.
  3. As Daniel and WiatroBosy said,
    If the file you are linking, i.e. about.html, is in the same directory with the file which has the a tag (<a href="about.html">), the link will work, else it will not work.

    But there are more disadvantages, those are:

    • Assume that the file that has the a tag, is index.html, and if the user visits example.com/index.html/ instead of example.com/index.html, i.e if the user visits the page with a slash at the end, it will break the link. Instead of the link going to example.com/about.html, it will go to example.com/index.html/about.html, which will probably result in the same page (index.html), or might result in a 404 error.

    • If you use the same for linking stylesheets using the link tag, the same above problem will occur.


    How to solve this?

    Use /path/to/about.html, I would suggest to never use about.html, and only use domain.com/about.html when the resource is in a different domain from the one the website is hosted on.

    So, your a tag would be <a href="/path/to/about.html">, or if it is in the root directory use <a href="/about.html">

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search