Error 404 converting .htaccess to web.config

0

My web server is IIS, so my .htaccess files don't work. Could you help me with the redirection and hiding the filename extension? My code gets a 404 error. I have two web.config files.

original .htaccess (1):

Options -MultiViews
RewriteEngine On
Options -Indexes

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

web.config (1):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="RewritePHP" stopProcessing="true">
      <match url="^(.+)$" />
      <action type="Rewrite" url="/index.php?url={R:1}" appendQueryString="true"/>
    </rule>
  </rules>
</rewrite>
 </system.webServer>
</configuration>

original .htaccess (2):

RewriteEngine on
RewriteRule ^(.*) public/$1 [L]

This web.config (2) works well (route the vhost to /public):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
<rewrite>
  <rules>
    <rule name="rewritepublic" stopProcessing="true">
      <match url="^(.*)" />
      <action type="Rewrite" url="public/{R:1}" />
    </rule>
  </rules>
</rewrite>
  </system.webServer>
</configuration>

Details error 404:

IIS Web Core
MapRequestHandler
StaticFile
0x80070002

URL request: http://localhost:81/site/public/page1
Path: C:\inetpub\wwwroot\site\public\page1
php
.htaccess
iis
web-config
asked on Stack Overflow Aug 21, 2018 by Giulia • edited Aug 22, 2018 by Giulia

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0