Switch HTACCESS to Web.config

Asked

Viewed 614 times

1

Hello, It is possible to convert this HTACCESS code to a Web.config file ?

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php?route=$1 [L,QSA]
  • What is the purpose of this conversion?

  • I’m putting a PHP application on a Windows 2008 server and the ISAPI that would make translating HTACCESS to the server not working, so I believe that if I can put it directly on the web.config it will work.

1 answer

3


Yes, it is possible.

There is this guide on the IIS page for the translation of the contents of a file .htaccess in an archive Web.config. It is not worth digging into the examples contained on the site in this reply.

For your case, where there are address rewrites, the following link can also help.

In the past example, it would look something like this:

<rewrite>
  <rules>
    <rule name="Regra 1" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
        <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
      </conditions>
      <action type="Rewrite" url="index.php?route={R:1}" appendQueryString="true" />
    </rule>
  </rules>
</rewrite>

I did not test this setting. I just did the translation based on the content of the question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.