简体   繁体   English

在 Azure 上的 PHP 7.4 中启用无扩展名的文件服务

[英]Enable serving of files with no extension in PHP 7.4 on Azure

I am running Wordpress on Azure under PHP 7.4 and require the ability to serve files with no file extensions on my PHP site. I am running Wordpress on Azure under PHP 7.4 and require the ability to serve files with no file extensions on my PHP site.

The url I am trying to load looks like this https://myurl.com/.well-known/acme-challenge/6uVkXzXxHHkm1d6cQiUqI07lrYspInk7i9WCKKl-RlQ我尝试加载的 url 看起来像这样https://myurl.com/.well-known/acme-challenge/6uVkXzXxHHkm1d6cQiUqI07lrYspInk7i9WCKKl-RlQ

Unfortunately no matter what I seem to do I am still getting a 404 Page Not Found error on WordPress despite the file existing on my server.不幸的是,无论我似乎做什么,我仍然在 WordPress 上收到404 Page Not Found错误,尽管我的服务器上存在该文件。

Typically in .NET applications all I need to do is add a configuration setting to the web.config like such to achieve the desired result.通常在 .NET 应用程序中,我需要做的就是将配置设置添加到 web.config 中,以实现所需的结果。

<system.webServer>
    <staticContent>
        <mimeMap fileExtension="." mimeType="text/html" />
    </staticContent>
</system.webServer>

I have also tried adding a custom .htaccess file with the following values.我还尝试添加具有以下值的自定义 .htaccess 文件。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\. - [H=text/html]

but unfortunately the error persists.但不幸的是,错误仍然存在。

Can anyone provide any guidance on how I might be able to get this working?任何人都可以提供有关我如何能够使其正常工作的任何指导吗?

So it turns out the mistake I was making was trying to place the file in a subfolder called wwwroot inside of wwwroot like you do with a .NET application.所以事实证明我犯的错误是试图将文件放在 wwwroot 内名为 wwwroot 的子文件夹中,就像使用 .NET 应用程序一样。

This was a mistake on my part having come from .NET.这是我的一个错误,来自 .NET。

Upon moving the file to the actual wwwroot folder I was able to successfully resolve my issue.将文件移动到实际的 wwwroot 文件夹后,我能够成功解决我的问题。

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

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