Reputation: 488
I have windows server for my website, the .htaccess file not working on my server so need to convert my .htaccess file to web.config file. Unable to convert .htaccess code to web.config... please help in convert the below .htaccess code to web.config code
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
by using the link: cbsa.com.br/tools/online-convert-htaccess-to-web-config.aspx
I have try to convert my .htaccess file and it given below code:
<rule name="rule 1U" stopProcessing="true">
<match url=".*" />
<action type="Rewrite" url="/index.php/{R:0}" />
</rule>
<rule name="rule 2U" stopProcessing="true">
<match url="(.*?)index\.php/*(.*)" />
<action type="Rewrite" url="//{R:1}{R:2}" />
</rule>
When I put this above code in my web.cofig file, my website showing below error...
Server Error 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed.
please suggest how to resolve this error...
Upvotes: 0
Views: 3582
Reputation: 488
After all my research and develpoment, I have used below code for web.config for my website at home directory
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="MyRule">
<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>
and in CI config/config.php change
$config['index_page'] = 'index.php'; ==> $config['index_page'] = '';
And its working fine.. url working like www.example.com/home without index.php
Upvotes: 2