gpt4 book ai didi

php - 如何从 wordpress 根文件夹的 web.config 文件中删除 .php 扩展名?

转载 作者:可可西里 更新时间:2023-10-31 23:02:47 24 4
gpt4 key购买 nike

我在 WordPress 根文件夹中有静态 PHP 页面。在 web.config 文件中,我将默认文件更改为静态 PHP 文件 home.php。我的网站有一些静态 PHP 页面和一些 WordPress 页面。对于 WordPress 页面,我使用永久链接更改了 SEO 友好的 URL,但静态 PHP 页面无法删除 .php 扩展名。

像这样:

http://reactore.com/contact-us/ --- WordPress 页面
http://reactore.com/about-us.php --- 静态 PHP 页面

这是我的 web.config 文件:

<rewrite>
<rules>
<rule name="WPurls" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:0}" />
</rule>
</rules>
</rewrite>

Click to view my web.config file at JSFiddle

最佳答案

在您的网络配置中使用此代码:

<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}.php" matchType="IsFile" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="{R:1}.php" />
</rule>
</rules>
</rewrite>

关于php - 如何从 wordpress 根文件夹的 web.config 文件中删除 .php 扩展名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34919912/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com