D
D
Dmitry Filandor2017-09-25 17:16:25
IIS
Dmitry Filandor, 2017-09-25 17:16:25

Why doesn't ASP site redirect from WWW?

Hello! There is a site (asp mvc 5) - poster when the site was a simple shared hosting, this code worked to redirect from www to non-www:

<rewrite> 
      <rules>
    
     
      <rule name="Remove WWW" patternSyntax="Wildcard" stopProcessing="true">
        <match url="*" />
        <conditions>
          <add input="{CACHE_URL}" pattern="*://www.*" />
        </conditions>
        <action type="Redirect" url="{C:1}://{C:2}" redirectType="Permanent" />
      </rule>
     
        <!--<rule name="Redirect to non-www" stopProcessing="true">
          <match url="(.*)" negate="false"></match>
          <action type="Redirect" url="http://city-afisha.com/{R:1}"></action>
          <conditions>
            <add input="{HTTP_HOST}" pattern="^city-afisha.com$" negate="true"></add>
          </conditions>
        </rule>
    -->
    
    
    
      </rules>
    </rewrite>

transferred to VPS - stopped working, does not redirect, writes Not Found. I tried another option (the one that is commented out) - the same does not work.
redirect module installed - joxi.ru/p27LoQU0963WA7

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Kuznetsov, 2017-09-25
@DarkRaven

it seems to me that you have a problem in <add input="{CACHE_URL}" pattern="*://www.*" />
Tat, it seems that there should be a regular expression, and you have a string.
If you look at:

  • https://stackoverflow.com/questions/7368665/proper...
  • https://stackoverflow.com/questions/41026717/redir...
- you may have seen them, then there is just a regular expression.
UPD. In general, you do not have redirects, but URL Rewrite.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question