StefanaB
StefanaB

Reputation: 183

How can i make correct URL rewrite condition?

I have to add some rules in rewrite.config for some pages that doesn't exist anymore. I added the conditions in the following patters, but they are not working:

<rule name="_Offisielt_nettsted" stopProcessing="true">
      <match url="_Offisielt_nettsted$" />
    <conditions>
      <add input="{HTTP_HOST}" pattern="^www.example.com$‎" />
    </conditions>
    <action type="Redirect" url="https://www.example.com/" appendQueryString="false" redirectType="Permanent" />
  </rule>

The initial broken url is <www.example.com/_Offisielt_nettsted> and i want to redirect to the homepage. Any ideas what I did wrong?

Upvotes: 0

Views: 58

Answers (1)

Jokies Ding
Jokies Ding

Reputation: 3494

It sounds just like a charset issue. I just replaced the domian name. But rewrite module say <www.jokies.com> doesn't match regex expression ^www.jokies.com$.

It return enter image description here

So I rewrite the ^ and $ and it works

<rule name="_Offisielt_nettsted" stopProcessing="true">
      <match url="_Offisielt_nettsted$" />
    <conditions>
                        <add input="{HTTP_HOST}" pattern="^www.example.com$" />
    </conditions>
    <action type="Redirect" url="https://www.example.com/" appendQueryString="false" redirectType="Permanent" />
  </rule>

enter image description here

Upvotes: 1

Related Questions