You need a web.config file instead of .htaccess for codeigniter

I still can’t get the web.config file to work no matter how I try it, but it doesn’t redirect to other pages. I use codeigniter and host the application on IIS platform, here is my .htaccess file, please, can anyone convert this code to web.config?

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /travel/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule> <IfModule !mod_rewrite.c> ErrorDocument 404 /index.php </IfModule> 
0
source share
1 answer

Your web.config file should look something like this:

 <?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> <httpErrors> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" path="/somedir/oops404.htm" responseMode="ExecuteURL" /> </httpErrors> </system.webServer> 

RewriteBase is not used in the web.config files as it is, so you may need to change the URL paths accordingly.

+2
source

Source: https://habr.com/ru/post/1258096/


All Articles