[英]How to remove .php extension from web.config file from wordpress root folder?
I have static PHP pages in the WordPress root folder.我在 WordPress 根文件夹中有静态 PHP 页面。 On the
web.config
file, I changed the default file to static PHP file home.php
.在
web.config
文件中,我将默认文件更改为静态 PHP 文件home.php
。 I am having a few static PHP pages and a few WordPress pages for my website.我的网站有一些静态 PHP 页面和一些 WordPress 页面。 For WordPress pages, I changed SEO friendly URL using permalinks, but static PHP pages not able to remove
.php
extensions.对于 WordPress 页面,我使用永久链接更改了 SEO 友好 URL,但静态 PHP 页面无法删除
.php
扩展名。
Like this:像这样:
http://reactore.com/contact-us/
--- WordPress page http://reactore.com/contact-us/
--- WordPress 页面http://reactore.com/about-us.php
--- static PHP page http://reactore.com/about-us.php
--- 静态 PHP 页面
This is my web.config
file:这是我的
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单击以在 JSFiddle 查看我的 web.config 文件
Use this code in your web config:在您的网络配置中使用此代码:
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.