Base URL - How to call the home link

前端 未结 5 797
囚心锁ツ
囚心锁ツ 2021-02-07 14:11

Here an example of my base URL


I would like to know how to call that base URL for t

相关标签:
5条回答
  • 2021-02-07 14:25

    What you need is the virtual directory name of your application/website.
    This is a server variable, and it is not possible to get it in HTML alone, you need some server side component, like PHP or ASP.NET.

    If you are in the root directory, you can try a relative link.
    So try using a . to indicate "from this folder"

    <a href="./">Home</a>
    


    Should your question actually concern the opposite direction, do this:

    <a href="../">Home</a>
    


    Or use an absolute link:

    <a href="/folder">Home</a>
    

    Or use a canonical link

    <a href="http://subdomain.domain.com/folder">Home</a>
    
    0 讨论(0)
  • 2021-02-07 14:28

    Concatenate host name with application path and http/https should give you home URL. code below

    <a href="https://@Request.Url.Host@Request.ApplicationPath">Home</a>
    
    0 讨论(0)
  • 2021-02-07 14:29

    ADLADS (A Day Late - A Dollar Short)
    I got here and can't relate to the dialog.
    For me, I find that I wanted

    <a href="/index.html">Home</a>
    

    Maybe someone else wants this?

    0 讨论(0)
  • 2021-02-07 14:31

    Try not to put anything in your HREF, that is, make an empty HREF.

    This works in latest Firefox, Chrome, Opera, Safari and IE7, IE8, IE9.

    0 讨论(0)
  • 2021-02-07 14:44

    test case

    It appears that if you are going to start your url (a url that depends on a base url that is) with a /, you need to specify that this is from the current directory level. Thus your link should be

    <a href="./">Home</a>
    
    0 讨论(0)
提交回复
热议问题