How to get current URL?

This question already has an answer here:

  • Get the current URL with JavaScript? 18 answers

  • In JavaScript:

    window.location 
    

    See the link below for more info:

    https://developer.mozilla.org/en-US/docs/Web/API/Window.location


    You need to do 2 steps:

  • open your text editor and put thest lines in it

    RewriteEngine On

    RewriteRule ^howtoloseweight/1$ /howtoloseweight/1.html [L]

  • save file as ".htaccess"

  • make a link <a href="/howtoloseweight/1">part 1</a> . Doing this the link will go to http://mywebsite.com/howtoloseweight/1 as you wish.

  • on the part 1 link of your first page (http://mywebsite.com/howtoloseweight) make the link as below

    <a href="http://mywebsite.com/howtoloseweight/1">part 1</a>
    

    or

    <a href="./1">part 1</a>
    

    on the second page (http://mywebsite.com/howtoloseweightfast/) make the link as below

    <a href="http://mywebsite.com/howtoloseweightfast/1">part 1</a>
    

    or

    <a href="./1">part 1</a>
    

    FYI :- "." always refers the current location.

    链接地址: http://www.djcxy.com/p/22546.html

    上一篇: 获取URL路径的部分

    下一篇: 如何获取当前网址?