in meta tag, url with slash vs url without slash [

2019-09-22 01:00发布

问题:

This question already has an answer here:

  • Difference between Relative path and absolute path in javascript 8 answers

What is the difference between:

<meta http-equiv="refresh" content="0; url=/file.html" />

and

<meta http-equiv="refresh" content="0; url=file.html" />

I am calling this from domain.com/folder/index.html The first one would redirect to the domain.com/file.html and the other one to domain.com/folder/file.html. Why?

回答1:

When you use "/" as the first character of the route you mean that the route starts from the root (domain.com/). If you don't use it, the route starts from the current location (domain.com/folder/).



回答2:

Using / indicates that the path begins in the root folder. This is called an absolute path.

If you avoid the slash you are using a relative path, so the path begins in the current folder.