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

Requested URL Not Found On This Server

Hi guys,

I think I've really messed up this time!

I've been working locally on adding a new page to a site I had done for a client (originally one page site) and was having troubles getting my anchor tag on the font page to redirect to the new page.

I kept getting an error saying the requested URL was not found.

I was able to view the new page if I signed into wp-admin and navigated to the "pages" section and then clicked "view" from the links beneath the page heading. Everything worked fine there.

But if I copied the URL from that and tried in another browser window, or tried typing the url myself I got the 404 error.

After doing some research on the problem I came across this article: https://turbofuture.com/internet/wordpress-not-found-error-fix

Thinking this might be my solution I went and changed my permalink settings to "Post Name" and then did CHMOD on my .htaccess file to 666 as he suggests.

This is where the fun began.

Now I get the 404 error when trying to view the page from the wp-admin "pages" section as well.

I tried reverting the permalink setting back to custom, as it was, and redoing CHMOD on .htaccess back to 644 but I still get the error.

As a last resort I tried restoring all my files from my last github commit and my last Time Machine backup but to no avail.

I'm really lost and don't know what to do.

Any help would be greatly appreciated.

Thanks in advance Don :-)

Well I've managed to fix one of my problems. I had the bright idea to copy the permalink setting from the live site over to my local environment and it did the trick so I can now view the page by navigating from the wp-admin "pages" section.

However I am still unable to navigate there from by button on my front page.

The "a" tag I generated the href by using "echo get_template_directory_uri()" and appending "/page-nagayu.php", which is what I called the page I am working on.

This throws a 500 error.

Checking the URL on the page I get redirected to it seems good. It is pointing to localhost:8080/ then the name of my client's folder and then "/wp-content/themes/hugsandkisses/page-nagayu.php", which is exactly right.

Oddly enough, if I just type some test text or some plain old HTML into my page template it works fine.

I don't get it.

Digging deeper I think I've found the cause, but no idea on the solution.

When I call get_header() it kills it. The same for get_footer();

Anything I have in my code before the get_header() is called renders just fine. Anything after it gets lost.

Anyone have any ideas on this?

1 Answer

First, what theme are you using? are you using wp_nav_menu() function to register a new nav, and adding the page to the nav in the backend?

did you flush your permalinks?

if not, it sounds like by doing this will reset your permalink structure so you won't get those errors.

wp dev

codex

by doing this it will reset your .htaccess file.

Hi Jacob,

Thanks for the reply.

Sorry I forgot to mention that my theme is a custom theme I built by converting a Bootstrap template over.

It looks like the wp_nav_menu() is part of my problem. I hadn't done any of that at all, just hard coded my ul/li tags in the header.php file. It seems I need a refresher course in WP Theme Development! :-)

I've gone ahead and done all of that and can successfully navigate to the new page using the navbar link.

I still have the original problem though, which is that I have a button with "Find Out More" midway down the page which should redirect to the new page. The href for that tag I have as: "<?php echo get_template_directory_uri() ?>/page-nagayu.php ?>"

This is still throwing the 500 error.

Any ideas on this one?

Thanks again for your help. Don :-)

Got it sorted. I wasn't using get_permalink() for my href.

Looks like I really do need that refresher course in WP development.

Thanks again for your help :-) Don

Not a Problem, I'm glad you got it sorted.