简体   繁体   中英

how to convert htaccess to web.config

i'm working on a website project, and i have to install the website on the client's server. He has a Godaddy windows account, which doesn't accepts .htaccess files, it uses web.config instead. I dont really know how to write web.config, an i'm in hurry also. I've tried to convert my htaccess with some online converters but of course it doesn't works also. Can you help me out please?

my htaccess:

Options -Multiviews
RewriteEngine On

# Allow any files or directories that exist to be displayed directly
RewriteCond ${REQUEST_URI} ^.+$
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml)$ [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]

RewriteCond %{REQUEST_FILENAME] !-d
RewriteCond %{REQUEST_FILENAME] !-f

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

What the generator generates from it as web.config:

<rule name="rule 1w" stopProcessing="true">
    <match url="^"  />
    <action type="Rewrite" url="/-"  />
</rule>
<rule name="rule 2w" stopProcessing="true">
    <match url="^(.+)$"  />
    <action type="Rewrite" url="/index.php?url={R:1}" appendQueryString="true"/>
</rule>

Aaand i fixed it in 2 minutes after i posted this question!

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Imported Rule 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" />
          </conditions>
          <action type="Rewrite" url="/index.php?url={R:1}"  appendQueryString="true" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM