• Hi guys,

    I’ve spent days reading different suggestions related to this (I believe common) issue.. but so far I haven’t found a solution.

    I changed my site to the ‘pretty’ permalinks (post name), and as I’m on a windows server, it caused configuration problems: “404 – File or directory not found”.

    Following this, my hosting provider added a web.config file for me, which has resolved the problem of the links on my site, however in doing so, it has blocked access to the image files, so my site now displays no images.

    It seems I can either have one or the other – pretty permalinks or images.

    This is the code in the web.config:

    
    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
            <rule name="wordpress" stopProcessing="true">
              <match url=".*" />
              <conditions logicalGrouping="MatchAll">
    	    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
              </conditions>
              <action type="Rewrite" url="index.php" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>
    

    Where am I going wrong?!

    Thanks in advance!!

    G

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi ,
    I think webserver can not identify mime type for images.
    You can add MIME type in <system.webServer> ,
    For example :

          <staticContent>
             <mimeMap fileExtension=".jpg" mimeType="image/jpeg" />
          </staticContent>

    After saving, you can restart the webserver.
    Mime types for images :

    image/gif
    image/png
    image/jpeg
    image/bmp
    image/webp

    Good luck .

    Thread Starter gch1985

    (@georginaholt)

    Hi Mohammad,

    Let me first say thank you for taking the time to reply to me!

    I’ve tried inserting the code between <system.webServer> and <rewrite> in the code that I’d previously used (see above). But it’s still not working. In fact now the layout is wrong too. The site uses a page builder (elementor) – could this be a factor in the problem (given the new layout issues)?

    Thanks again!
    G

    Hi,
    This is a sample web.config :

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <directoryBrowse enabled="true" />
            <staticContent>
                <mimeMap fileExtension=".jpg" mimeType="image/jpeg" />
                <mimeMap fileExtension=".jpeg" mimeType="image/jpeg" />
                <mimeMap fileExtension=".gif" mimeType="image/gif" />
                <mimeMap fileExtension=".png" mimeType="image/png" />
                <mimeMap fileExtension=".bmp" mimeType="video/bmp" />
            </staticContent>
        </system.webServer>
    </configuration>

    First, test top code, if this code is running true, then test/use bottom code:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <directoryBrowse enabled="true" />
            <staticContent>
                <mimeMap fileExtension=".jpg" mimeType="image/jpeg" />
                <mimeMap fileExtension=".jpeg" mimeType="image/jpeg" />
                <mimeMap fileExtension=".gif" mimeType="image/gif" />
                <mimeMap fileExtension=".png" mimeType="image/png" />
                <mimeMap fileExtension=".bmp" mimeType="video/bmp" />
            </staticContent>
        <rewrite>
          <rules>
            <rule name="wordpress" stopProcessing="true">
              <match url=".*" />
              <conditions logicalGrouping="MatchAll">
    	    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
              </conditions>
              <action type="Rewrite" url="index.php" />
            </rule>
          </rules>
        </rewrite>
        </system.webServer>
    </configuration>

    Note: after save web.config , you must restart web-server.
    Documents: https://bit.ly/2tvrK5o

    Good luck.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘web.config stops images displaying’ is closed to new replies.