Transfer .htacces to web.config, 302 redirect

1k views Asked by At

How to translate this .htaccess to web.config file to work properly, and is it right name web.config of that file?

RewriteEngine On
RewriteBase /

RewriteRule ^(.*)$ http://www.mynedomain.com/$1 [R=302,L]
1

There are 1 answers

0
Justin Iurman On BEST ANSWER

Yes, this is in web.config file that you have to do it.

You can add a rewrite block into it for your rule

<rewrite>
  <rules>
    <rule name="Redirect to new domain" stopProcessing="true">
      <match url="^(.*)$" />
      <action type="Redirect" url="http://www.mynedomain.com/{R:1}" redirectType="Found" />
    </rule>
  </rules>
</rewrite>

In your htaccess code, you have a 302 redirect (that's why i used Found in the rule).
If you want instead a 301 redirect, replace Found by Permanent in the action tag of the rule.