简体   繁体   中英

GoDaddy Web.Config URL Rewrite not working

I have this web config:

<?xml version="1.0"?>

<configuration>
  <configSections>
  </configSections>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <!--maxRequestLength = maximum upload size =- 4096KB = 4MB-->
    <httpRuntime maxRequestLength="409600000"/>
  </system.web>

  <system.webServer>
    <rewrite>
      <rules>
        <!--The following rule will only work when published-->
        <rule name="Construction" stopProcessing="true">
          <match url="Construction\.aspx" negate="true"/>
          <conditions>
            <!-- dont ignore my own ip -->
            <add input="{REMOTE_ADDR}" pattern="XXX.XXX.XXX.XXX" negate="true"/>
          </conditions>
          <action type="Redirect" url="Construction.aspx" redirectType="Found"/>
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

</configuration>

It works on IIS on my local machine, but on other machines, I end up with the following problems:

  1. I get a 500 error when the rewrite portion is included. When I remove it everything works fine.
  2. I can't get the debug output to print to the screen.

What's wrong with it?

In a case where I use rewrite , I'm not escaping periods in match's url attribute. Have you tried <match url="^Construction.aspx$" negate="true"/> ?

Admittedly this is a stretch, as it's been a while since I've dug into the docs for this.

I have followed the answer by @CohenA Detailed 500 error message, ASP + IIS 7.5 to help with the full details for 500 errors. I just leave it commented out until I run into an error so I don't have to remember it.


Have you reviewed this answer for the ReWrite issue? Unsure of what you're trying to do with the ReWrite, but perhaps you want to use Rule #2

< match url="^Construction$" />

Or, are you missing the leading / on the ReDirect?

< action type="Redirect" url="/Construction.aspx" redirectType="Found"/>

I've only gotten as far as adding to the < configuration > tags :

<configSections>
      <sectionGroup name="system.webServer">
           <sectionGroup name="rewrite">
                <section name="rewriteMaps" overrideModeDefault="Allow" />
                <section name="rules" overrideModeDefault="Allow" />
           </sectionGroup>
     </sectionGroup>
</configSections>

so now it doesn't error out, but it also doesn't read the rewrites

You may try the below config. This has rewrite block which will redirect the requests that come to the folder to an index.php page and will also output the detailed error instead of custom/generic error page. This is tested on Godaddy windows hosting IIS 8.5. Hope this helps!

<configuration>
 <system.webServer>
    <httpErrors errorMode="Detailed"></httpErrors>
    <asp scriptErrorSentToBrowser="true"></asp>
    <rewrite>
     <rules>
      <rule name="your rule" stopProcessing="true">
       <match url="(.*)$"  ignoreCase="false" />
       <conditions>        
        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />        
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />        
       </conditions> 
       <action type="Rewrite" url="index.php?request={R:1}"  appendQueryString="true" />
      </rule>
     </rules>
    </rewrite>
  </system.webServer>
  <system.web>
    <customErrors mode="Off"></customErrors>
    <compilation debug="true"></compilation>
  </system.web>
</configuration>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM