I keep trying to convert the web.config file from my old server to the new one, which is using Ubuntu server, but I can't get the things done right. Can you guys help me to convert the code bellow to .htaccess?

    <rewrite>
  <rules>
    <rule name="Rule IIS7">
      <match url="^([a-zA-Z0-9-_.]+)(___)([0-9]+)(.*?)$" ignoreCase="false" />
      <conditions>
        <add input="{SCRIPT_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
        <add input="{SCRIPT_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
      </conditions>
      <action type="Rewrite" url="post.php?redir=1&amp;id={R:3}" appendQueryString="false" />
    </rule>
    <rule name="Rule IIS7 2">
      <match url="(.*?)(_\!__)([0-9]+)(.*?)$" ignoreCase="false" />
      <conditions>
        <add input="{SCRIPT_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
        <add input="{SCRIPT_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
      </conditions>
      <action type="Rewrite" url="links/cota_clicks.php?redir=1&amp;url={R:3}" appendQueryString="false" />
    </rule>
    <rule name="Redirect to WWW" stopProcessing="true">
      <match url=".*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^todoespacoonline.com$" />
      </conditions>
      <action type="Redirect" url="http://www.todoespacoonline.com/{R:0}" redirectType="Permanent" />
    </rule>
    <rule name="Redirect to COM" stopProcessing="true">
      <match url=".*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^todoespacoonline.com.br$" />
      </conditions>
      <action type="Redirect" url="http://www.todoespacoonline.com/{R:0}" redirectType="Permanent" />
    </rule>
    <rule name="Redirect to .COM" stopProcessing="true">
      <match url=".*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="todoespacoonline.com.br$" />
      </conditions>
      <action type="Redirect" url="http://www.todoespacoonline.com/{R:0}" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>

I really couldn't do that on my own.

That wasn't really the same thing, but worked really well for me...

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{REQUEST_URI} ([a-zA-Z0-9-_.]+)(___)([0-9]+) [NC]
RewriteRule ^([a-zA-Z0-9-_.]+)(___)([0-9]+)(.*?)$ post.php?redir=1&id=$3

Hello, plz convert to htaccess ?

 <rewrite>
            <rules>
                <rule name="Redirection Https" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
                </rule>
                <rule name="REWRITE_TO_HTML" stopProcessing="true">
                    <match url="^(.+).html$" />
                    <conditions logicalGrouping="MatchAll" />
                    <action type="Redirect" url="{R:1}.sn" />
                </rule>
                <rule name="REWRITE_TO_PHP" stopProcessing="true">
                    <match url="^(.+).php$" />
                    <conditions logicalGrouping="MatchAll" />
                    <action type="Redirect" url="{R:1}.sn" />
                </rule>
                <rule name="test1">
                    <match url="^(.*)\.sn" />
                    <action type="Rewrite" url="{R:1}.php" />
                </rule>
                <rule name="tttt" stopProcessing="true">
                    <match url="^(.+).php(.+)" />
                    <action type="Redirect" url="{R:1}.sn{R:2}" />
                </rule>
                <rule name="tttt1" stopProcessing="true">
                    <match url="^(.+).html(.+)" />
                    <action type="Redirect" url="{R:1}.sn{R:2}" />
                </rule>
            </rules>
        </rewrite>
    <rewrite>
        <rules>
            <rule name="block favicon" stopProcessing="true">
                <match url="favicon\.ico" ></match>
                <action type="CustomResponse" statusCode="404" subStatusCode="1" 
                    statusReason="The requested file favicon.ico was not found" 
                    statusDescription="The requested file favicon.ico was not found" ></action>
            </rule>
            <rule name="Imported Rule 1" stopProcessing="true">
                <match url="^(.*)$" ignoreCase="false" ></match>
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^mvc3$" ></add>
                </conditions>

                <action type="Redirect" redirectType="Permanent" url="http://localhost/LandlordApp/{R:1}" ></action>
            </rule>
            <rule name="Imported Rule 2" stopProcessing="true">
                <match url="^(.*)$" ignoreCase="false" ></match>
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" ></add>
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" ></add>
                    <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" ></add>
                </conditions>
                <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" ></action>
            </rule>
        </rules>
    </rewrite>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.