admin管理员组

文章数量:1129618

In permalinks(dashboard) section index.php added. e.g.

Current Post Name: .php/sample-post/
Expected Post Name: /

How can i remove index.php?

Note: I am using windows server

In permalinks(dashboard) section index.php added. e.g.

Current Post Name: http://zakatchicago.com/index.php/sample-post/
Expected Post Name: http://zakatchicago.com/sample-post/

How can i remove index.php?

Note: I am using windows server

Share Improve this question edited May 20, 2015 at 12:16 m4n0 1,36410 silver badges22 bronze badges asked May 20, 2015 at 11:05 Kaizur AhmedKaizur Ahmed 811 silver badge4 bronze badges 0
Add a comment  | 

2 Answers 2

Reset to default 1

As of WP 5.9 (but I am sure way back years and versions) there is no need to add web.config manually.

In case IIS rewrite module is installed (whichi is a prerequisite) when you modify Settings/Permalink, WP automatically emits web.config into the root of your site.

It even writes to the GUI a warning message, to revoke write access from web.config.

If IIS rewrite module is not installed, all of this above is not possible, neither manually, so WP will include the /index.php/ fragment in the path. If you overwrite this setting with a custom permalink setting, then the links will adopt (so will not contain the /index.php/ fragment, but because of lack of rewrite facility IIS will give 404.

According to the documentation here: http://www.iis.net/learn/extensions/url-rewrite-module/enabling-pretty-permalinks-in-wordpress

I assume you have already selected Post Name in your permalink structure:

Then include this code in web.config

<rewrite>
<rules>
    <rule name="Main Rule" 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" />
    </rule>
</rules>
</rewrite>

本文标签: Remove indexphp in permalink structure on IIS server