Forum Moderators: open

Message Too Old, No Replies

.htaccess to web.config

         

Sub_Seven

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

10+ Year Member



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.

whitespace

11:14 am on Jan 19, 2019 (gmt 0)

10+ Year Member Top Contributors Of The Month



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...).

Sub_Seven

3:36 pm on Jan 21, 2019 (gmt 0)

10+ Year Member



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.

Sub_Seven

3:43 pm on Jan 22, 2019 (gmt 0)

10+ Year Member



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