Skip to content

Posts by lfenney

WordPress 404 – File or directory not found, broken Images, multisite image path error.

Easy IT Support - 2

Facebook
Instagram

Resolving WordPress 404 errors – File or directory not found, broken Images in WordPress, and multisite image path error.

We created these notes after troubleshooting errors when setting up WordPress on Microsoft IIS and  getting WordPress 404 errors .  The file or directory not found, broken Images in WordPress, multisite image path error. We are hoping this will help others who are setting up a new WordPress website on IIS.

We are also running WPLMS as our current WordPress theme. Which is a large enterprise premium Learning Management System for WordPress.

Resolving WordPress 404 Errors

File or directory not found, broken Images in WordPress, and multisite image path error.

1. Enabling Pretty Permalinks in WordPress
2. Windows Server and IIS
3. Installing and Configuring WordPress to work on IIS.
4. Setting Up WordPress on IIS
5. HTTP 404.0 when opening a page in WordPress.
6. 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
7. Getting Images to display in WordPress
8. WPLMS HTTP 404.0
9. Multisite image path error

See our YouTube video detailing the below steps below: https://youtu.be/HlEQlB54AB8

First, we will look at the 404 - File or directory not found error when any sub-page is opened on the site.

404 - File or directory not found and image path error.

Below were the errors we were getting on a new setup and install of WordPress and WPLMS.

Note: This could more than likely fix other issues with WordPress and other themes. This is not necessarily related to WPLMS Theme but more of an issue with our WordPress install and set up on Windows Server 2012 R2.

  • From a client: 404 - File or directory not found

404 error and WPLMS and WordPress

  • And in some cases: HTTP Error 404.0 - Not found

404 error and WPLMS and WordPress 2

Testing to see if the Permalink Settings are the issue:

To quickly see if you are having the same issue as we did.  Add the following to your Custom Structure in the WordPress Permalink Setting page:

Settings--> Permalink 

/index.php/%year%/%monthnum%/%day%/%postname%/

Permalink Setting

Not all the pages may work yet.  Keep checking to see if some work and others don't.  As a test, you may also want to switch back to a default WordPress themes such as Twenty Fifteen.

If some pages are now working and others don't try adding the following next.  Or, if none of the sub-pages are displaying yet and you're still getting the 404.0 Error try the following too!

Note: Don't worries if the images aren't working yet.  We will get to that soon!

Is URL Rewrite Installed?

If not see below: Web Platform Installer.

In IIS make sure URL Rewrite is installed.  It was installed in our default install of IIS. If not, see below.

URL Rewrite

Is the Web Platform Installer?

If the Web Platform Installer is not installed you need to add it to install the URL rewrite  (yep, install this too. https://www.microsoft.com/web/downloads/platform.aspx.  Don't worry its a very simple install).

Microsoft Web Platform Installer

Installing URL Rewrite:

Simply do a search for the installer (URL Rewrite) and Add it to IIS.  Do not configure it.  We will get some things added to it later.

URL Rewrite

Configuring Web.Config:

Add the below text to Web.Config where your site is configured:  (e.g. ..wwwrootwordpressWeb.Config).

Open the Web.config file that is located in the same directory where the WordPress files are installed, and paste the below XML section into the system.webServer element.

This rule will try to match any requested URL. If the URL does not correspond to a file or a folder on the file system, it will rewrite the URL to the Index.php file. At that point, WordPress will determine which content to serve based on the REQUEST_URI server variable that contains the original URL before it was modified by this rule.

<rewrite>
<rules>
<rule name="Main Rule" 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>

This is how are Web.Config looked after we made the change:

Web.Config

Save the file.  Reopen it and make sure the changes have been applied.  Restart IIS.

IIS Restart

After adding the above rewrite code to the Web.Config file you will see this in IIS URL Rewrite.  Make sure you have your website folder highlighted and not another location in IIS (e.g /wordpress). There should not be a need to add anything else.  When we when back into IIS and looked at Match setting it look to be different then what we pasted in the Web.Config file.

URL Rewite

 

This is what it should look like for both REQUEST_FILENAME.

  • Is Not a File
  • Is Not a Directory

Note: We tested this and when we set it to "Is a File" and Is a Directory" it broke the pages again.  So, leave it set as the screenshot shows.

URL Rewrite 5

 

Now you can try to test the site and see if it works, but we are not done.

Changing the Permalink Settings:

We changed our Permalink Setting back to Post name because our install of WPLMS highly suggested that this be set this way.  We could not tell if that broke anything leaving it to Custom Structure or not.  You may be OK leaving it.  We did NOT and we switched it to Post name.

 

Permalink Settings Post Name2

 

Images added to a WordPress page are not being displayed:

Finally, new images we added to a WordPress page don't seen to be displaying even though they are in the Media Library.

Add this to the root folder .htaccess file. Restart IIS. (Getting Images to display in WordPress).

Note: by default WordPress does not create a .htaccess file.  Simply create this file using word in the root folder of your WordPress site.  Make sure it has the dot (.) in front of the file.  See the screenshot below.

Note: you may need to show hidden files and folders in Explorer to see this.  IF you don't see it then go ahead and create it.  We had to create one.  Make sure it is .htaccess

htacess 3

Add the below to the .htacess file.  Stop and Start IIS.

Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all

Folder Permissions:

Finally, set the correct file permissions on the site (e.g. /WordPress) folder for the IIS_USER.  Open Explore and set the file permissions.

folder folder permissions

Select Advanced -->  Then select the Replace all child permissions...

permissions

Goodluck!  If you need additional help with WordPress you can contact us at www.EasyITSupport.com.

Other things to try, and links to other related topics:

If your still having issues here are a few more thinks to look at.

Permissions:

Setting permission on wp-content folder.

wp-content

IIS_IUSRS

1. Change the permissions on the temp folder giving IIS_IUSRS write/modify.

2. Change the path of the temp folder in the PHP.ini file to a folder that does have IIS_IUSRS write/modify permission.

Here is a good source detailing the problem:

http://www.howyoudo.info/index.php/how-to-fix-windows-server-upload-file-inherit-permissions-error/

I chose to move the temp folder in my PHP.ini to C:inetpubtempuploads and also give it permissions.

After uploading an image in wp-admin, I was able to access the image (original, not resized) from a browser wihout the 500.50 error.

 

Installing WordPress on IIS:

Install Internet Information Services 8.5 and WordPress 3.x by Using the Microsoft Web Platform Installer 5.0

https://codex.wordpress.org/Installing_on_Microsoft_IIS

https://codex.wordpress.org/Install_Internet_Information_Services_7.0_and_WordPress_3.0.3_by_Using_the_Microsoft_Web_Platform_Installer_3.0

 

If you would like help with this or other WordPress issues and design please call us or complete the form below:

Completed: Berry’s Barber Shop

Berry’s Barber Shop

Site Completed

About Berry’s Barber Shop

Clarence “Buck” Berry began cutting men’s hair at this location in 1910. Passed the business onto his son Jim who provided quality haircuts and shaves until 2013 when Michael the Barber purchased Berry’s Barber Shop. Michael continues to run the business with the same attention to customers, quality haircuts and good old time conversation the Shop has always been known for.

Updated: Welch Bros., Inc.

Welch Bros., Inc.

Site Updated

http://www.WelchBrothers.com

About Welch Bros., Inc.

Welch Bros., Inc. engineers and manufactures a wide variety of precast concrete products including sanitary sewer systems, storm drainage systems, septic tanks, round and elliptical pipe, construction barrier walls and flared end sections to name a few. Our experienced workforce takes great pride in their workmanship, delivering the finished product timely and efficiently. We look forward to meeting with you to discuss your specific construction needs.

Complete: KB Utility Services

KB Utility Services

Project Completed

About KB Utility Services

KB Utility Services is a family owned and operated business headquartered in the Chicagoland Area. Bob Nickolson founder and President, has worked in the telecommunications  industry since 1980.  KB Utility Services has expanded to provide complete CATV construction,  fiber optic construction, HDD/directional drilling, HDPE pipe fusion, and natural gas construction.

The rest of KB Utility Services management team is highly dedicated and has been a part of the KB Utility Services family for an average of 16 years.

KB Utility Services is committed to the Midwest region. KB Utility Services is a company you can rely on to provide your project with the best quality, on time and on budget performance. Our customer focused service has built client relationships that continue to return for help with their CATV, drilling, pipe fusion, natural gas and other construction needs

Complete: NUI Underground

Northwest Utilities Illinois Underground

Project Complete

http://www.nuiunderground.com

They feature a range of services in underground construction. At NUI Underground horizontal directional drilling guarantees high quality services. Our top priority is attaining positive customer responsiveness, to achieve this we must have the most sophisticated equipment to get the job done. Having experienced and skilled operators ensure that the job will be of top quality without sacrificing efficiency.

Complete: U.S. Air Force Reserve

U.S. Air Force Reserve

Project Completed

http://BrooksAFCR.com

Air Force Reserve

eLearning site for U.S. Air Force Reserve. IMPACT Selling Professional Certification Program is a self-study course designed to elevate your knowledge and application of the IMPACT Sales Model to a level only a few recruiting professionals will ever achieve. Earning your professional certification is similar to receiving a Graduate Degree in professional selling. The rewards that go along with joining the elite few who have achieved this level of expertise are many. Here are just some of the benefits you will enjoy

Complete: Quantum Sign Corp.

Quantum Sign Corp.

Project Complete

http://www.quantumsigncorp.com

Chicagoland Business Signs and Sign Repairs

With an award-winning design team, our trusted professionals deliver custom-made products and are able to overcome any challenge with a head-on approach that covers all phases of the sign process.

Our signs are tailored to your company’s individual requirements, with guidance and advice available from our experienced staff along the way. Expect to dramatically boost your company’s corporate profile with professional and striking sign solutions. Whatever the need, you can always depend on us to provide the highest quality and most cost-effective comprehensive sign solutions to fulfill your requirements.

Complete: Welch Bros., Inc.

Welch Bros., Inc.

Project Completed

http://www.WelchBrothers.com

About Welch Bros., Inc

Welch Bros., Inc. engineers and manufactures a wide variety of precast concrete products including sanitary sewer systems, storm drainage systems, septic tanks, round and elliptical pipe, construction barrier walls and flared end sections to name a few. Our experienced workforce takes great pride in their workmanship, delivering the finished product timely and efficiently. We look forward to meeting with you to discuss your specific construction needs.

Call Now Button