无法使用 4D 更改默认主页

can't change the default homepage with 4D

我正在尝试按照本教程从 4d 服务器 Web 开始。 http://doc.4d.com/4Dv16/4D/16/Serveur-Web.200-3246839.fe.html

我已禁用默认主页 index.html(甚至删除了 WebFolder 文件夹中的实际文件)和然后在 On Web Connection 方法中添加了这几行

C_TEXT()
Case of
  :(="/")
     WEB SEND FILE("new_index.html")
End case

但当我转到 localhost:8080/ 时,我仍然看到 4d 默认页面 然后我发现该方法甚至没有被调用,除非我向 url 添加一些东西(比如 localhost:8080/something)

如果您在数据库设置中将 index.html 列为默认主页,那么它将加载该页面(如果它不存在,有时它会创建它)。

此外,使用 html 扩展不会 运行 任何动态代码,要调用代码,您必须使用 shtml扩展名或文件不能存在(找不到文件时触发OWA/OWC)。

此技术提示仍然适用,并且很好地运行详细说明了在什么情况下使用网络连接(和网络身份验证)方法运行:
Tech Tip: How to skip over HTTP and redirect to HTTPS: Part 2 (The Web decoy folder)

引用:

The On Web Authentication database method is (by default) only called in the following situations:

  • when 4D receives a URL beginning with 4DACTION/
  • when 4D receives a URL beginning with 4DMETHOD/
  • when 4D receives a URL beginning with 4DCGI/
  • when 4D receives a URL requesting a static page that does not exist
  • when 4D processes a 4DSCRIPT tag in a semi-dynamic page
  • when 4D processes a 4DLOOP tag based on a method in a semi-dynamic page.

Note: The On Web Authentication database method expects a Boolean value to be returned in [=10=]; True = request accepted, False = request rejected. The default value if [=10=] is not returned is True which means all requests are accepted.

The On Web Connection database method is (by default) called in the following cases:
When connecting a browser to a 4D Web server operating in contextual mode. The database method is called with the /... URL.

  • When 4D receives the /4DMETHOD URL. The Web server switches to contextual mode and the database method is called with the /4DMETHOD/MethodName URL in .
    When 4D receives the /4DCGI URL. The database method is called with the /4DCGI/ URL in .
  • When a Web page is called with a URL of type / that is not found. The database method is called with the URL as .
  • When a Web page is called with a URL of type / and no home page has been defined by default. The database method is called with the URL as .

So (by default) if the web visitor is requesting a page, and that page exists in the webfolder at the location specified in the URL, that page will be automatically sent back to the customer without any special processing. This is fine in most situations but the developer can gain much greater control over the requests by implementing a web decoy folder.

因此,如果您希望 /url 到 运行 您的代码,您可以使用以下任一方法:

  • 使用 index.shtml(注意 shtml 中的 s
  • 删除数据库设置中的条目(因此默认页面字段为空)

在 4D 中修改 Web 配置选项时,用户设置 将优先于 数据库设置

如果启用了用户设置,请确保选中用户设置和数据库设置。

可在以下菜单选项下访问用户设置: