maxxd Posted May 16, 2017 Share Posted May 16, 2017 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. Quote Link to comment https://forums.phpfreaks.com/topic/303945-webconfig-redirect-rules/ Share on other sites More sharing options...
kicken Posted May 16, 2017 Share Posted May 16, 2017 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> Quote Link to comment https://forums.phpfreaks.com/topic/303945-webconfig-redirect-rules/#findComment-1546561 Share on other sites More sharing options...
maxxd Posted May 16, 2017 Author Share Posted May 16, 2017 Thanks much for your time, unfortunately this returned a 500 internal error. Don't know if it makes a difference, but the site is hosted on GoDaddy. Quote Link to comment https://forums.phpfreaks.com/topic/303945-webconfig-redirect-rules/#findComment-1546563 Share on other sites More sharing options...
requinix Posted May 17, 2017 Share Posted May 17, 2017 What does the error log say? Quote Link to comment https://forums.phpfreaks.com/topic/303945-webconfig-redirect-rules/#findComment-1546570 Share on other sites More sharing options...
maxxd Posted May 17, 2017 Author Share Posted May 17, 2017 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. Quote Link to comment https://forums.phpfreaks.com/topic/303945-webconfig-redirect-rules/#findComment-1546575 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.