简体   繁体   English

Laravel项目的Azure Web App错误404

[英]Azure Web App error 404 with Laravel project

I have a project coded in Laravel that works pretty good on localhost. 我有一个用Laravel编码的项目,可以在localhost上很好地工作。

I uploaded it on Azure from a git repository. 我将其从git存储库上传到Azure。 When I try to access the pages, I get this message: 当我尝试访问页面时,收到以下消息:

"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable." “您正在寻找的资源已被删除,名称已更改或暂时不可用。”

I already googled the problem I am having but nothing seems to work. 我已经用谷歌搜索了我遇到的问题,但似乎没有任何效果。

EDIT: 编辑:

My Azure WebApp is set to access site\\wwwroot\\public\\ as the application. 我的Azure WebApp设置为访问site \\ wwwroot \\ public \\作为应用程序。

Click here to see the picture showing what I said above 单击此处查看显示我上面所说的内容的图片

As nothing I tried worked, I deleted the app on Azure and created another one. 由于没有任何尝试,我在Azure上删除了该应用程序并创建了另一个。 This time, it worked. 这次,它奏效了。 I don't know why. 我不知道为什么 Probably my older files was corrupted somewhere..I don't know. 我的旧文件可能在某个地方损坏了。。我不知道。

This issue can be fixed by putting the web.config file in the public folder. 可以通过将web.config文件放在公用文件夹中来解决此问题。

https://github.com/Azure-Samples/laravel-tasks/blob/master/public/web.config https://github.com/Azure-Samples/laravel-tasks/blob/master/public/web.config

 <configuration> <system.webServer> <rewrite> <rules> <rule name="Imported Rule 1" stopProcessing="true"> <match url="^(.*)/$" ignoreCase="false" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> </conditions> <action type="Redirect" redirectType="Permanent" url="/{R:1}" /> </rule> <rule name="Imported Rule 2" stopProcessing="true"> <match url="^" ignoreCase="false" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> </conditions> <action type="Rewrite" url="index.php" /> </rule> </rules> </rewrite> </system.webServer> </configuration> 

More details on the whole process here: https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-php-mysql 有关整个过程的更多详细信息,请参见: https : //docs.microsoft.com/zh-cn/azure/app-service/app-service-web-tutorial-php-mysql

The error suggests that the file you are looking for is not present on the server or you have not properly configured your web.config file. 该错误表明您要查找的文件不存在于服务器上,或者您没有正确配置web.config文件。

If you are using any special file name i would suggest you to look through FTP that the file is present on the servers. 如果您使用任何特殊的文件名,我建议您通过FTP查看服务器上是否存在该文件。

I would suggest you enable diagnostic logging for Web Apps to get detailed error messages and logs. 我建议您为Web Apps启用诊断日志记录,以获取详细的错误消息和日志。

Also, check if it is a deployment or a runtime issue as described here: https://github.com/projectkudu/kudu/wiki/Deployment-vs-runtime-issues 另外,按照此处所述检查它是部署问题还是运行时问题: https : //github.com/projectkudu/kudu/wiki/Deployment-vs-runtime-issues

Since Laravel uses \\public as the entry point and .htaccess file is not recognizable by Azure Web App, could you try setting the virtual directory to site\\wwwroot\\public in Application settings via Azure portal ? 由于Laravel使用\\public作为入口点,并且Azure Web App无法识别.htaccess文件,您是否可以尝试通过Azure门户应用程序设置中将虚拟目录设置为site\\wwwroot\\public

在此处输入图片说明

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

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