Share via

How to fix URL Rewrite in IIS for Git install on Server 2025

Pruitt, James R 0 Reputation points
2026-01-29T18:21:06.0866667+00:00

Having issues getting "Git for Windows" working with Win11 and Server 2025. Specifically with the XML web.config code below and the error with URL Rewrite that follows. Instructions on the web are: "How to Set Up a Git Repository on IIS for HTTP/HTTPS Push-Pull Team Access" I'm attempting for HTTPS setup in IIS.

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

<system.webServer>

<!-- Enable CGI -->  

<handlers>  

  <add name="git-http-backend"  

       path="*"  

       verb="*"  

       modules="CgiModule"  

       scriptProcessor="C:\Program Files\Git\mingw64\libexec\git-core\git-http-backend.exe"  

       resourceType="Unspecified"  

       requireAccess="Execute"  

       preCondition="bitness64" />  

</handlers>  



<!-- URL Rewrite to pass repo path to git-http-backend -->  

<rewrite>  

  <rules>  

    <rule name="Git HTTP Backend" stopProcessing="true">  

      <match url=".*" />  

      <action type="Rewrite" url="git-http-backend.exe/{R:0}" />  

      <serverVariables>  

        <set name="GIT_HTTP_EXPORT_ALL" value="1" />  

        <set name="GIT_PROJECT_ROOT" value="C:\inetpub\git" />  

        <set name="PATH_INFO" value="/apps.git/{R:0}" />  

      </serverVariables>  

    </rule>  

  </rules>  

</rewrite>  



<!-- Enable server variables for URL Rewrite -->  

<security>  

  <requestFiltering allowDoubleEscaping="true" />  

</security>  
```  </system.webServer>  

Git tracing errors produced during an attempted Clone from server to desktop ->

</configuration>  

09:37:23.394302 http.c:915              == Info: schannel: SSL/TLS connection renegotiated

09:37:24.563648 http.c:862              <= Recv header, 0000000040 bytes (0x00000028)

09:37:24.563648 http.c:874              <= Recv header: HTTP/1.1 500 URL Rewrite Module Error.

09:37:24.563648 http.c:862              <= Recv header, 0000000025 bytes (0x00000019)

09:37:24.563648 http.c:874              <= Recv header: Content-Type: text/html

09:37:24.563648 http.c:862              <= Recv header, 0000000028 bytes (0x0000001c)

09:37:24.563648 http.c:874              <= Recv header: Server: Microsoft-IIS/10.0

09:37:24.563648 http.c:862              <= Recv header, 0000000037 bytes (0x00000025)

09:37:24.563648 http.c:874              <= Recv header: Date: Thu, 29 Jan 2026 17:37:25 GMT

09:37:24.563648 http.c:862              <= Recv header, 0000000022 bytes (0x00000016)

09:37:24.563648 http.c:874              <= Recv header: Content-Length: 1208

09:37:24.563648 http.c:862              <= Recv header, 0000000002 bytes (0x00000002)
Windows development | Internet Information Services
0 comments No comments

2 answers

Sort by: Most helpful
  1. Danny Nguyen (WICLOUD CORPORATION) 6,785 Reputation points Microsoft External Staff Moderator
    2026-01-30T10:48:45.4666667+00:00

    Hi,

    It looks like the failure isn’t Git itself—your client is getting HTTP 500 “URL Rewrite Module Error”, which usually means the rewrite rule is erroring before git-http-backend.exe runs.

    In your web.config the key thing is you are using <serverVariables>. On IIS, setting server variables via URL Rewrite is blocked unless you explicitly allow it. If the server variables aren’t allowed/unlocked, URL Rewrite will return exactly this 500 error.

    Things to check on Server 2025:

    1. URL Rewrite: “Allowed Server Variables”
      • IIS Manager → your server (or site) → URL RewriteView Server Variables
      • Add/allow at least:
        • GIT_HTTP_EXPORT_ALL
        • GIT_PROJECT_ROOT
        • PATH_INFO
    2. Enable “Allow Server Variables” for the rule
      • After adding them, recycle the app pool / restart IIS and re-test.
    3. Confirm CGI is installed/enabled
      • Server Manager → Add Roles/Features → Web Server (IIS) → Application Development → CGI
    4. Get the detailed rewrite error
      • Check Windows Event Viewer and/or enable Failed Request Tracing (FREB) for the site; it will tell you exactly which part of the rule is failing.

    Hope to hear from you soon.

    1 person found this answer helpful.

  2. Q&A Assist
    2026-01-29T18:21:15.8666667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To address the URL Rewrite issue you are experiencing with IIS while setting up Git for Windows, consider the following steps:

    1. Check the Rewrite Rule: Ensure that the rewrite rule is correctly configured. The action URL in your rule should point to the correct path of the git-http-backend.exe. You may want to adjust the action URL to include the full path, like so:
         <action type="Rewrite" url="C:\Program Files\Git\mingw64\libexec\git-core\git-http-backend.exe/{R:0}" />
      
    2. Server Variables: Make sure that the server variables are set correctly. The GIT_PROJECT_ROOT should point to the directory where your Git repositories are stored. Ensure that the path is accessible by the IIS user.
    3. Permissions: Verify that the IIS user has the necessary permissions to execute the git-http-backend.exe and access the Git repository directory. You may need to adjust the permissions on the folder C:\inetpub\git.
    4. Enable CGI: Ensure that the CGI feature is enabled in IIS. You can do this through the Server Manager by adding the CGI feature if it is not already installed.
    5. Check for Malformed XML: If you are receiving an HTTP 500 error, it could be due to malformed XML in your web.config. Ensure that the XML structure is correct and that there are no syntax errors.
    6. Failed Request Tracing: Consider enabling Failed Request Tracing in IIS to get more detailed error messages regarding the URL Rewrite module. This can help you identify what is going wrong during the rewrite process.
    7. Consult Logs: Check the IIS logs for more specific error messages that could give you insight into what might be causing the rewrite to fail.

    By following these steps, you should be able to diagnose and fix the URL Rewrite issues you are encountering with your Git setup on IIS.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.