IIS UrlRewrite is not working for IIS 8

怎甘沉沦 提交于 2019-12-08 23:35:44

问题


I have just moved my website to new computer which uses IIS 8 from one has IIS 7.5. All but URL rewriting is working well. there is no error message than "HTTP Error 404.0 - Not Found" which I got. What I've only recognized is, there is an entry like RewriteModule (%SystemRoot%\system32\inetsrv\rewrite.dll) in website>modules setting page but, IIS 8 one has no same module. Even though I added same module to IIS 8, It didn't work. I'll be glad if I can have some suggestion about how to solve the problem. More info could be provided upon request..

Hope I could expressed what i mean properly.!

Thanks in advance,

alper

ps: url rules work well..


回答1:


first of all you have to check if rewrite url works well, follow this sample tutorial:

http://www.iis.net/learn/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules

If not, open IIS8 and check if URL rewrite icon is showing. If not download msi from here:

http://www.iis.net/downloads/microsoft/url-rewrite

and reinstall the module. Now you could see the URL Rewrite module in IIS manager while on the root node (Server node) as well as on website and web application nodes.

Hope it helps!




回答2:


I had forgotten to add the bindings for the domains to redirect from. E.g. redirect to https://www.example.com usually needs the following bindings:

  • https://www.example.com
  • https://example.com
  • http://www.example.com
  • http://example.com

These redirection rules (from SO) then worked for me:

<rule name="Redirect from non www" stopProcessing="true">
    <match url=".*" />
    <conditions>
      <add input="{HTTP_HOST}" pattern="^example.com$" />
    </conditions>
    <action type="Redirect" url="https://www.example.com/{R:0}" redirectType="Permanent" />
  </rule>
  <rule name="Redirect from non https" stopProcessing="true">
    <match url=".*" />
    <conditions>
      <add input="{HTTPS}" pattern="^OFF$" />
      <add input="{HTTP_HOST}" pattern="^www.example.com$" />
    </conditions>
    <action type="Redirect" url="https://www.example.com/{R:0}" redirectType="Permanent" />
  </rule>



回答3:


I spent a couple of hours solving this issue. There are steps I went through and got the rewrite module to work fine.

  1. Reinstall rewrite module. If you don't see this module in IIS and installed application list but rewrite installer says thar is is already installed go to registry (HKLM/SOFTWARE/MICROSOFT/WINDOWS/CURRENTVERSION/Uninstall) and serach 'rewrite'. Find uninstall string and run it. It will remove rewrite module and you can install from scratch.
  2. Install Application Request Routing module for IIS.
  3. IMPORTANT! If you already have web.config with rules remove them. Create/add rules via IIS menu. This way IIS will activate ARP module that is important.



回答4:


I also had this problem. As the OP noticed, the .dll is not registered. The installer says everything is fine, the rewrite icon is there in IIS Manager, but it's not working. Check the .dll is there (see path below). Use microsoft notepad, Really, I'm NOT joking, it has to be microsoft notepad, not even visual studio will work for this. Start notepad as Administrator and open C:\Windows\System32\inetsrv\Config\applicationHost.config

Add the following line to the <globalModules> node.

<add name="RewriteModule" image="%SystemRoot%\system32\inetsrv\rewrite.dll" />

Save, and try your rules now.

Really it has to be notepad, if you try editing applicationHost.config on a 64bit system with anything else, you're going to be pulling your hair out for hours. One of the weirdest windows anomalies I've ever seen. http://weblog.west-wind.com/posts/2008/Aug/09/Editing-Applicationhostconfig-on-64-bit-Win2008 http://dpotter.net/technical/2009/11/editing-applicationhostconfig-on-64-bit-windows/




回答5:


For me, my URL re-write worked in IIS7.5 but not in IIS8

The issue was the pattern

In IIS7.5 I had the pattern written as off

In IIS8 I had to update it to ^OFF$




回答6:


Open IIS Manager > Server > Modules > Configure Native Modules In the list, select RewriteModule and click OK

IIS Config

This works for me.




回答7:


I just had a similar issue after a Windows Service 2008 to Windows Service 2012 update and although I haven't completely tested this, all I did was uninstall/re-install the rewrite module specifically.

Hope this helps anyone having the same issue.




回答8:


It helped checking and fixing the rewrite rules. I know it worked earlier and I am not aware of changing it.




回答9:


You could try this method. After a little google search, you're not the only one with this problem --> http://forums.iis.net/t/1173537.aspx/1




回答10:


Also check: Make sure this setting is false because otherwise after URL Rewriting rewrites the URL, the .NET application might re-route it back.

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">



回答11:


I could not find what caused the problem but I've just solved it today with re-installation windows server and IIS 8.

Thanks for your interest and valuable time,

alper



来源:https://stackoverflow.com/questions/14607390/iis-urlrewrite-is-not-working-for-iis-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!