Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

localhost 404 Errors

Hi guys,

I'm having real issues with my local development environment and really can't seem to find a solution.

Forgive me if this is long-winded and confusing, but I'll try to explain where I'm at.

My problems began while building out the blog section of a client's site. I was adding in the pagination functionality and noticed I was getting 404 errors when clicking on the pagination links for all but the first page.

After researching it for a bit it seemed the recommended course of action was to go to the WP Admin Permalink Settings and just re-save them, which I did.

This broke things even further. I started to get 404 errors for all pages on the site except the home page. What's more, the errors didn't render my 404.php file but just a generic blank page with "NOT FOUND The url blah-blah-blah.php was not found on this server".

Researching that, the most common fix seemed to be to update my .htaccess file to read like this:

# BEGIN WordPress

RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

So I did that and it hasn't changed anything.

As a last resort I thought I would download all the files from the live site and see if that worked.

This just generated the same 404 error message, but I noticed it was redirecting to https://, rather than http://.

I researched how to get https:// on my localhost and found an article which recommended I download and install Local by FlyWheel, which I did.

And it seems that has REALLY done it. Now I get the same generic blank page with the 404 error for every one of my local WP sites.

I really don't know what to do to fix it.

I've tried contacting some other developers in my local area for help but no-one seems willing to help me.

I'm hoping someone on here has an idea of how to go about fixing my issues.

Thanks in advance, Don

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Was everything working fine (did you test) before you made any changes?

Thanks Dave,

Yes everything was working fine up until the time I started getting the 404 errors from my pagination links. From there it seems it's just been a never-ending procession of errors getting me deeper into trouble.

1 Answer

Patricia Hector
Patricia Hector
42,901 Points

Can you show me the URL that is generated when you get the 404 on your local dev?

Hi Patricia,

It is generating this: http://localhost:8080/Clients/BubsWorldDev/wp-admin/install.php

Which is weird as the folder containing the files is named "Bubs World Dev" and should (and used to) generate http://localhost:8080/Clients/Bubs%20World%20Dev/wp-admin/install.php

I think it's something to do with the rewrite rule in my .htaccess file

Patricia Hector
Patricia Hector
42,901 Points

Are you using wp-admin folder to do something? Where is your theme folder?

Hi Patricia,

I'm not using the wp-admin folder for anything other than the bundled WordPress files which come with the install. I haven't touched any of them.

My theme folder lives in wp-content/themes. The full path, from my MAMP Apache Server is Clients>Bubs World Dev>wp-content>themes>dmwd-bubsworld

I've made another discovery in the last day. Initially I thought this problem was specific to WordPress sites, but I had an idea to go back and check a site I built purely on PHP/MySQL and it doesn't work either.

Then I logged into PHPMyAdmin from my MAMP server and tried to run some basic SELECT queries and nothing works there either.

i.e. When I am in PHPMyAdmin I can see all of my databases, and all of the tables within the databases. Then when I go to the SQL tab and enter a basic query of SELECT * FROM wp_options I get an error message saying

#1146 - "Table wp_bubsworld.wp_options" doesn't exist

I've tried the same query on all of the tables which are part of the database and get the same result. I've checked my spelling of the table names to make sure, and I am not making typos, and I have the relevant database selected so I am not sure why it is throwing the error.

The same result happens for every database I have.

Digging even further, if I click on one of the tables in any of my databases under the "Structure" tab and the "Information" section it is showing as 0 Space Usage for Disk, Index and Total.

I just created a new random database and input one row of dummy data into a table and these fields all show with values. I can also run queries on the dummy database.

So it would seem I have somehow lost all of the data stored in all of my databases.

This may have been when I restored a previous version of my MAMP/db/mysql56 folder from a Time Machine backup.

I'm really lost.

Alena Holligan Andrew Chalkley Hampton Paulk

If any of you guys can suggest anything I'd be supremely grateful :-)

Cheers, Don

Patricia Hector
Patricia Hector
42,901 Points

Really lost with your problem Don. I hope you had not lost all the data. The last idea: Did you backup the last data before restoring it with the older version?

Hi Patricia,

Thanks for taking the time to read over everything.

Can't say I blame you for not understanding my problem - I'm having a hard time myself. What started as a simple pagination error has morphed into myriad problems with each solution I have tried along the way. I think I'm going to just work backwards from my latest problem (PHP MyAdmin tables not showing data) and take it one at a time from there.

I have backups all over the place so that shouldn't be a problem.

Thanks again.