是什么区别/和〜/相对路径? [英] What is the difference between / and ~/ relative paths?

查看:138
本文介绍了是什么区别/和〜/相对路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这两种类型将带给你的根文件夹,但显然,他们的工作方式不同,一旦你做一个URL重写。

I thought that both types would bring you to the root folder, but apparently, they work differently, once you do a URL rewrite.

例如,我通常使用/我知道会带给你的根文件夹,它当一个URL被重写。

For instance, I normally use / which I know will bring you to the root folder and it does when a URL has been rewritten.

当别人试图用〜/网址已被重写后,则路径未能找到该文件。这是为什么?

When someone else tried to use ~/ after a URL has been rewritten, then the path fails to find the file. Why is that?

推荐答案

/将带你回你的网站的根目录。

/ will take you back to the root of your website.

〜/将带你到你的网站上的应用程序的主文件夹。

~/ will take you to the home folder of your application on the website.

如果您的应用程序是一个叫对myApp,例如文件夹中,这样的URL看起来像这样

If your application is in a folder called myApp, for example, so the URL looks like this

http://www.YourSite.com/myApp/ 

和在应用程序中使用〜/脚本/ jquery.js和引用,然后将路径

and in your application you use ~/Scripts/jquery.js then the path referenced will be

http://www.YourSite.com/myApp/Scripts/jquery.js

而只是用/将一路送你回网站的根目录

whereas just using / would send you all the way back to the root of the website

http://www.YourSite.com/Scripts/jquery.js

这篇关于是什么区别/和〜/相对路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆