Jump to content

Recommended Posts

Hey y'all.

 

I just went live with a client site yesterday - I had written the .htaccess rules to redirect any existing bookmarks to the corresponding new pages, tested those, and was ready to go. Then, lo and behold, the client's on an IIS 7 server. I haven't looked at IIS in years and am now having some issues with attempting to translate the Apache redirects to IIS redirects.

 

It should be told that the site is a WordPress site, and I got the rewrite rule working as expected.

 

Back to the redirects, I've tried the following in the rewrite.rules node of my web.config file:

<rule name="contractors">
	<match url="^contractors\.html$"/>
	<action type="Redirect" url="contractors/" appendQueryString="false" redirectType="Permanent"/>
</rule>

I've also tried:

<rule name="contractors">
	<match url="^(.*)"/>
	<conditions>
		<add input="{URL}" pattern="contractors.html"/>
	</conditions>
	<action type="Redirect" url="contractors/" appendQueryString="false" redirectType="Permanent"/>
</rule>

There was another method that involved the definitions in a separate file and linking to that from within the web.config as a map of sorts that I tried (I'm sorry, I'm a bit fried by it all and I tried this method yesterday and ditched the code when it didn't work).

 

Neither of the above quoted code blocks actually did anything. By that I mean that visiting //myclientsite/contractors.html served a 404 page instead of redirecting to //myclientsite/contractors/ as expected. There were some other variations that immediately caused a server 500 fault, so I know the web.config is being touched each time the page is refreshed (please see earlier disclaimer when considering the fact that I've not quoted the variations...).

 

Anyone have any ideas/suggestions/swift kicks to the head about where I may be going wrong? Many thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/303945-webconfig-redirect-rules/
Share on other sites

Try something like this:

<rewrite>
    <rules>
        <rule name="Old Contractors" patternSyntax="ExactMatch" stopProcessing="true">
            <match url="contractors.html" />
            <action type="Redirect" url="/contractors/" appendQueryString="false" type="Permanent" />
        </rule>
    </rules>
</rewrite>

According to tech help, apparently IIS doesn't actually create an error log. Which is awesome. I'm doing some digging into how to enable verbose error messages, I just hate doing that on a production server, even for a short amount of time.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.