且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

网站部署后相对路径不起作用

更新时间:2023-02-09 23:18:37

站点是否已部署到域的根目录?如果网站位于

Is the site deployed to the domain's root? If the site is at

http://example.com/somefolder/

然后将路径/stylesheet/main.css解释为

http://example.com/stylesheet/main.css

而不是

http://example.com/somefolder/stylesheet/main.css

如@Kit所示,您可以通过解析应用程序文件夹的路径来解决此问题.我经常在ASP.NET中这样做,如下所示:

As @Kit indicated, you can work around this by resolving the path to your application's folder. I have often done this in ASP.NET as follows:

<link rel="stylesheet" type="text/xss" href="<%= ResolveUrl("~/stylesheet/main.css") %>"/>

如果这不是问题,那么您将不得不提供更多细节.

If that's not the problem, you're going to have to give a bit more detail.