简体   繁体   English

如何访问本地主机根目录之外的文件?

[英]How to access files outside of root directory in localhost?

I have some common angular files one-level outside of my local site's root directory, like so: 我在本地站点的根目录之外一级存在一些通用的角度文件,如下所示:

-- angular.js
-- angular-sanitize.js
-- root
   |-- index.html
   |-- client.js
   |-- style.css

I want to link the files to index.html , so I tried something like (for angular.js), 我想将文件链接到index.html ,所以我尝试了类似的方法(对于angular.js),

  • ../angular.js
  • /G:/User/angular.js
  • ./../angular.js

but none of them worked out. 但他们都没有解决。 Why it is so and how to do it correctly? 为什么会这样以及如何正确执行呢?

EDIT: I'm using a Python server. 编辑:我正在使用Python服务器。

You cannot access files outside your htdocs folder because your server considers that to be the root folder. 您无法访问htdocs文件夹之外的文件,因为您的服务器将其视为根文件夹。 Hence has no parent folder. 因此没有父文件夹。 Or in basic terms, your apache server is only available in your htdocs folder. 或基本而言,您的apache服务器仅在htdocs文件夹中可用。 So you might have to move your files there or give a link to them online. 因此,您可能必须将文件移到那里或在线链接到它们。

Conclusion: There is no way you can do that. 结论:无法做到这一点。

Or maybe you have to edit your httpd.conf file 或者,也许您必须编辑httpd.conf文件

您必须将整个项目放在服务器文件夹(htpdocs,http等)中,然后在项目内部使用--.. / somescript.js之类的链接来访问文件夹外部的文件,但不能访问服务器空间

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM