Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy PHP application on IIS

I am trying to deploy my CODEIGNITER application on IIS server. My test script hello word is working on IIS but when I move my CI application and checked error log says 404 for any url. I tried to add web.config file for rewrite rules on root still error occur here is web.config file

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
  <rewrite>
          <rules>
              <rule name="Index">
              <match url="^(.*)$" />
              <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
              </conditions>
                    <action type="Rewrite" url="index.php/{R:1}" />
            </rule>
          </rules>
        </rewrite>
    </system.webServer>
</configuration>
like image 317
Vipin Sharma Avatar asked Apr 07 '26 06:04

Vipin Sharma


1 Answers

try this web.config

<?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Rewrite to index.php">
                        <match url="index.php|robots.txt|images|test.php" />
                        <action type="None" />
                    </rule>
                    <rule name="Rewrite CI Index">
                        <match url="^(.*)$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php/{R:1}" appendQueryString="false" /> </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>

In the config.php file, change $config['uri_protocol']= 'QUERY_STRING' to $config['uri_protocol'] = 'AUTO'.

like image 53
Devidas Kadam Avatar answered Apr 09 '26 18:04

Devidas Kadam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!