Welcome to WebmasterWorld Guest from 100.24.209.47

Forum Moderators: ocean10000

.htaccess to web.config

     
3:59 am on Jan 19, 2019 (gmt 0)

Junior Member

5+ Year Member

joined:June 18, 2010
posts: 170
votes: 1


Hello everyone,

I recently moved a website from hostgator (Apache server) to an Azure App Service (IIS) and I'm having issues transferring the .htaccess rewrite rules to web.config.

I tried using the IIS manager to convert the rules but when I try the page I get the following error: "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."

This is the original .htaccess rule: RewriteRule ^tours/([^/]+) /tours?n=$1 [NC]

This is what IIS manager translated it to:

<rule name="Imported Rule 2">
<match url="^tours/([^/]+)" />
<action type="Rewrite" url="/tours?n={R:1}" appendQueryString="false" />
</rule>

Can anyone please help me understand what is wrong here?

Thanks in advance for any help provided.
11:14 am on Jan 19, 2019 (gmt 0)

Full Member

Top Contributors Of The Month

joined:Apr 11, 2015
posts: 328
votes: 24


Was your original .htaccess file in the document root of your site?

You can try removing the slash prefix on the action "url" parameter (although I doubt that this will make a difference). In other words:


<action type="Rewrite" url="tours?n={R:1}" .....


What is significant with your RewriteRule is that there is no "L" flag, so processing continues and is possibly rewritten again? The IIS rules will continue by default, but I don't know how they chain together (with mod_rewrite, the output of the last is the input of the next and so on...).
3:36 pm on Jan 21, 2019 (gmt 0)

Junior Member

5+ Year Member

joined:June 18, 2010
posts: 170
votes: 1


Thanks whitespace,

I tried your suggestion but yeah, this didn't make a difference. I'll analyze my options, if you have any other suggestions please send them over.

Have a nice day.
3:43 pm on Jan 22, 2019 (gmt 0)

Junior Member

5+ Year Member

joined:June 18, 2010
posts: 170
votes: 1


Hello,

Just posting a reply to inform I fixed it with the rule below, note that it only worked when I applied it first before any other rules, otherwise it will still send an error:


<rule name="Rewrite to tours.php">
<match url="^tours/([_0-9a-z-]+)" />
<action type="Rewrite" url="tours?n={R:1}" />
</rule>

Thanks