6 Replies - 468 Views - Last Post: 16 January 2015 - 09:39 PM Rate Topic: -----

#1 Akemi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 16-January 15

Unable to get 404.php to work site-wide

Posted 16 January 2015 - 08:58 PM

For the past few days, I have been stressing out BIG TIME trying to figure out how to fix one page on my website. I am trying to make a custom 404 error page using a wordpress theme that is no longer updated. I am trying to add a background image using CSS, an HTML table of social media icons(using CSS and HTML), and add a search bar over the image. I am doing all this while trying to get PHP to work with CSS and HTML with no knowledge of PHP. I have tried EVERYTHING and I still do not know what I did wrong. I have tried making a new 404.php, editing the active 404, using HTACCESS errordocument thing, and a few other things that I've forgotten. It seems the PHP itself MIGHT be working because when I click on the PHP file after I've converted it, it seems to display correctly but when I try and simulate entering a non-existent page on my website, I do not get the 404 page I made, I get something different two times, something that looks like it is trying to look like my 404 page but fails to execute the CSS and HTML included. I tried this first on my website directly but I ended up messing up the website layout and the background image(CSS) ended up becoming my website's background. So I reinstalled the theme and then moved to a local host and installed the same theme there. I've included the image of what the original 404 page looks like(first), what I'm trying to get it to look like/what it looks like when I follow the PHP link directly(it has an anime girl), and an image of what I get when I try and follow a link that would trigger a 404.

The codes are as follows:

1) The code of the original 404 page I am trying to completely change:

<?php
/**
 * The template for displaying 404 pages (Not Found).
 *
 */

get_header(); ?>

	<div id="primary" class="content-area">
		<main id="main" class="site-main" role="main">

			<section class="error-404 not-found hentry">
				<header class="page-header">
					<h1 class="entry-title"><?php _e( 'Oops! That page can&rsquo;t be found.', 'fictive' ); ?></h1>
				</header><!-- .page-header -->

				<div class="page-content">
					<p><?php _e( 'It looks like nothing was found at this location. Maybe try one of the links below or a search?', 'fictive' ); ?></p>

					<?php get_search_form(); ?>

				</div><!-- .page-content -->
			</section><!-- .error-404 -->

		</main><!-- #main -->
	</div><!-- #primary -->

<?php get_footer(); ?>




NEXT is the code of the PHP I ended up making:

<?php
/** 
 * The template for displaying 404 pages (Not Found).
 *
 * UGUU 404 theme
 */
 
?>




<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link rel='stylesheet' type='text/css' href='404style.css' /><div class="icons">
  <table width="35" border="0">
    <tbody>
      <tr>
        <td><a href="https://twitter.com/Otaku2012" target="new"><img src="twitter.png"></a></td>
        <td><a href="http://www.myanimelist.net/profile/Lolicon"><img src="MAL.png"></a></td>
        <td><a href="https://www.facebook.com/AkemiCNN"><img src="facebook.png"></a></td>
        <td><a href="#"><img src="crunhyroll.png"></a></td>
        <td><a href="#"><img src="googleplus.png"></a></td>
        <td><a href="#"><img src="instagram.png"></a></td>
        <td><a href="#"><img src="youtube.png"></a></td>
        <td><a href="#"><img src="reddit.png"></a></td>
        <td><a href="#"><img src="linkedin.png"></a></td>
        <td><a href="#"><img src="rss.png"></a></td>
        <td><a href="#"><img src="email.png"></a></td>
      </tr>
    </tbody>
  </table>
</div>
</div>
<div class="footer">
<p class="copyright"> ALL RIGHTS RESERVED</a></p>

</div>
<!-- /layout-container -->




If you wish for the CSS code I made and/or with what the theme came with, I'll post it if needed.

I know, my pathetic 404 code doesn't look right(to me anyway) but it seemns to be working as a PHP but it's not working as a 404.php, even when I delete the original PHP and rename the new php as 404.php. It doesn't use the CSS I apply to it from a CSS file either. I have no idea where the CSS that the OLD 404 code is/was using but I have 3 CSS that came with the theme.

I have scanned the internet for days and tried every option with no success, so now I am hoping someone can help me get my PHP working.

Sorry, this thing I end up with if I try and provoke a 404 error is this.

(Notice: No background, and the broken image icons and copyright are on the top instead of bottom)

Attached image(s)

  • Attached Image
  • Attached Image
  • Attached Image
  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Unable to get 404.php to work site-wide

#2 astonecipher  Icon User is offline

  • Too busy for this
  • member icon

Reputation: 2329
  • View blog
  • Posts: 9,356
  • Joined: 03-December 12

Re: Unable to get 404.php to work site-wide

Posted 16 January 2015 - 09:06 PM

The default 404's stylesheet is set in the header file, yours is a relative path, not absolute. In my opinion, error pages are something that putting the style tags in is acceptable.

One issue you may run into is browser cache.


But, is your 404 loaded into the correct theme directory? Does it have the same name as the previous?
Was This Post Helpful? 0
  • +
  • -

#3 Akemi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 16-January 15

Re: Unable to get 404.php to work site-wide

Posted 16 January 2015 - 09:13 PM

Yes. It is loaded in the same theme under the same name(404.php). The only difference is that the entire 404 has been redone and it is using a separate CSS. The fact it loads correctly when linked directly but fails to load when it is needed as an error document completely stumps me.

This post has been edited by Dormilich: 19 January 2015 - 01:02 AM

Was This Post Helpful? 0
  • +
  • -

#4 astonecipher  Icon User is offline

  • Too busy for this
  • member icon

Reputation: 2329
  • View blog
  • Posts: 9,356
  • Joined: 03-December 12

Re: Unable to get 404.php to work site-wide

Posted 16 January 2015 - 09:15 PM

And by fails to load correctly, you mean it is missing the CSS, correct?
Was This Post Helpful? 0
  • +
  • -

#5 Akemi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 16-January 15

Re: Unable to get 404.php to work site-wide

Posted 16 January 2015 - 09:23 PM

Yes, I believe so. Is this easily fixable?

This post has been edited by Dormilich: 19 January 2015 - 01:02 AM

Was This Post Helpful? 0
  • +
  • -

#6 astonecipher  Icon User is offline

  • Too busy for this
  • member icon

Reputation: 2329
  • View blog
  • Posts: 9,356
  • Joined: 03-December 12

Re: Unable to get 404.php to work site-wide

Posted 16 January 2015 - 09:25 PM

You can verify that is the issue by checking your browser console for the error.

As I said above, you need to either use an absolute path to the CSS, or include it in the page and that should fix it.
Was This Post Helpful? 1
  • +
  • -

#7 Akemi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 16-January 15

Re: Unable to get 404.php to work site-wide

Posted 16 January 2015 - 09:39 PM

I am getting multiple error codes when I attempt to provike a 404, but they are all the same and all point to either the broken image icons or the css that fails to load: "Failed to load resource: the server responded with a status of 404 (Not Found)"

I tried to use the CSS absolute suggestion before and I tried it using every path and had no success, but I just realized I forgot to exclude "public_html" and instead replace it with my website name....I have had success after DAYS of stressing. Thank you so much!

This post has been edited by Dormilich: 19 January 2015 - 01:03 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1