0

i'm trying to deploy a Symfony 5 app on IIS10

  • In IIS the site points to the public folder.

  • I did create a "web.config" file.

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <defaultDocument>
          <files>
              <add value="index.php" />
          </files>
        </defaultDocument>
      <rewrite>
          <rules>
              <rule name="Rewriter" stopProcessing="true">
                 <match url="^(.*)$" ignoreCase="false" />
                 <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                 </conditions>
                 <action type="Rewrite" url="./index.php" appendQueryString="true" />
              </rule>
          </rules>
      </rewrite>
     </system.webServer>
    </configuration>
    

When I go to this url "http://192.168.1.87:89/" which is the main page of my site.

Or any other route, it's the same thing

I get the following error

This page does not work 192.168.1.87 has redirected you too many times.

Try deleting the cookies.

ERR_TOO_MANY_REDIRECTS

I have of course deleted the cookies as indicated but it does not work.

Edit : I did what @BruceZhang said, so I deleted the url rewrite file and defaulted to the index.php file but now I get a 404 NOT FOUND, The resource you are looking for has been deleted, renamed or is temporarily unavailable.

enter image description here

  • 1
    You're redirecting all routes to index.php. so then when the browser requests index.php, it will be redirected to index.php, which will then redirect to index.php, and so on forever.. it's an infinite loop. You need to make sure the redirect rule doesn't apply to index.php – ADyson Sep 03 '21 at 10:15
  • @ADyson Thanks for your answer, I understand better now, but after several searches I don't see how to make the rule apply to all but "index.php", does it involve a regular expression or adding a condition in my web config that says that the url requested must be different from "index.php"? – Swen De Bentzmann Sep 03 '21 at 11:59
  • I don't have much direct experience of IIS rewrite rules myself but this answer seems to contain a technique which would help you - it is excluding certain specific items from a rule. See https://stackoverflow.com/a/13320891/5947043 – ADyson Sep 03 '21 at 12:25
  • So what's your real need? For example which url rewrite to which url, which url doesn't rewrite to which url? – Bruce Zhang Sep 06 '21 at 08:56
  • @BruceZhang In fact I don't have any url that works, normally it's index.php that says to which it controller redirects depending on the url the user types. In my case I have no url that works. Or if I type my url like this 192.168.1.87/login it gives me the error "ERR_TOO_MANY_REDIRECTS" . What I'm looking for is to make all my routes work. Maybe Symfony doesn't work well with IIS? – Swen De Bentzmann Sep 06 '21 at 12:30

1 Answers1

1

I'm not an expert on Symfony. Is index.php a file?

If it is, you can add it in default document module(enable it) so that http://192.168.1.87 will show index.php page. Then you don't need to use url rewrite for it. 192.168.1.87/login will not redirect to index.php any more. enter image description here enter image description here

If you want to redirect some url to other url, http://xxxxx/abc => http://xxxx/xyz, I think you need to learn how to use url rewrite in Microsoft document, or you can let me know.

Bruce Zhang
  • 2,880
  • 1
  • 5
  • 11