x
 
Create New Page
 View Previous Changes    ( Last updated by Brian Mallett )

Removing index.php with web.config

Side by side code sample for removing index.php with web.config instead of .htaccess

Hopefully seeing it side by side can help make the connection.

web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <
system.webServer>
        <
rewrite>
            <
rules>
                <
rule name="Index.php" stopProcessing="true">
                    <
match url="^site/?(.*)$" ignoreCase="false" />
                    <
conditions logicalGrouping="MatchAll">
                        <
add input="{THE_REQUEST}" pattern="^POST" ignoreCase="false" negate="true" />
                    </
conditions>
                    <
action type="Redirect" url="/{R:1}" redirectType="Permanent" />
                </
rule>
                <
rule name="File exception" stopProcessing="true">
                    <
match url="^(.*)$" ignoreCase="false" />
                    <
conditions logicalGrouping="MatchAll">
                        <
add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    </
conditions>
                    <
action type="Rewrite" url="/index.php/{R:1}" />
                </
rule>
            </
rules>
        </
rewrite>
    </
system.webServer>
</
configuration

.htaccess

RewriteCond %{THE_REQUEST} !^POST
RewriteRule 
^site/?(.*)$ /$1 [R=301,L]

RewriteCond 
%{REQUEST_FILENAME} !-f
RewriteRule 
^(.*)$ /index.php/$1 [L]