我在Apache上有一个WebServer (CentOS),它有一个Blazor应用程序,如果DocumentRoot直接设置在index.html所在的位置,应用程序就能工作,但如果不是,它会读取index.html并显示加载屏幕,但不会加载。澄清:
应用程序定位:/var/www/sometestfolder/main/wwwroot
WORKS
DocumentRoot "/var/www/sometestfolder/main/wwwroot":
通过:example.com访问
不工作:
DocumentRoot "/var/www":
通过:example.com/sometestfolder/main/wwwroot访问
(显示“加载.一个未处理的错误发生了。重新加载”文本的blazor应用程序,但似乎没有加载作为一个,因为“一个未处理的错误发生了”不应该在那里。
问:为什么第二个案例不起作用?有办法让它发挥作用吗?还是我做错了一切?
我认为我发布的应用程序不正确(ftp发布到服务器,结果是www.root文件夹和web.config文件),这导致应用程序运行在任何虚拟主机的需要上,微软手动声明一个blazor应用程序需要这个虚拟主机来工作:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias *.example.com
DocumentRoot "/var/www/blazorapp"
ErrorDocument 404 /index.html
AddType application/wasm .wasm
AddType application/octet-stream .dll
<Directory "/var/www/blazorapp">
Options -Indexes
AllowOverride None
</Directory>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE application/octet-stream
AddOutputFilterByType DEFLATE application/wasm
<IfModule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/htmlErrorLog /var/log/httpd/blazorapp-error.log
CustomLog /var/log/httpd/blazorapp-access.log common来源:https://learn.microsoft.com/es-es/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-6.0
(向下滚动做"Apache")
发布于 2022-08-25 02:38:19
任何对其他文件的引用(css、图像、js、.)在index.html中,将在目录"/var/www“中搜索。
例
加载CSS文件"css/file.css"
DocumentRoot定义了网站文件的“虚拟/”或根。
我希望您的日志(Apache或应用程序)中出现错误,表明它找不到文件。您可能需要增加日志记录(LogLevel)才能获得更多细节。
https://stackoverflow.com/questions/73479896
复制相似问题