|
#1
Aug 2, 2011, 11:27 PM
|
|
Hi,
I need to redirect 404's to a custom 404 page saved as draft, not published.
How do I do this?
|
#2
Aug 3, 2011, 05:38 AM
|
|
|
|
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
|
|
by it's nature, a draft page won't be displayed
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
|
#3
Aug 3, 2011, 08:57 AM
|
|
Alright, tried saving the 404 draft page as complete web page, then uploaded to root of my server.
Typing "http://mysite.com/404.html" at the browser address bar displays the custom 404 page fine, but how do I configure Atahualpa to load this page for site 404's?
|
#4
Aug 19, 2011, 01:07 AM
|
|
Any resolution on this?
|
#5
Aug 19, 2011, 04:40 AM
|
|
|
|
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
|
|
there are two ways a 'Not Found can occur
1) a page just doesn't exist
2) you search for something that is not found
Case 1
In this case you need a 404.php file in the theme folder. Here is an example for release 3.6.7
HTML Code:
<?php
/**
* for displaying 404 pages (Not Found).
**/
?>
<?php
list($bfa_ata, $cols, $left_col, $left_col2, $right_col, $right_col2, $bfa_ata['h_blogtitle'], $bfa_ata['h_posttitle']) = bfa_get_options();
get_header();
extract($bfa_ata);
?>
your code goes here
<?php get_footer(); ?>
This will format the page like any other page on your site
case 2:
In this case, edit index.php and look at the bottom where you will see
HTML Code:
<h2><?php _e('Not Found','atahualpa'); ?></h2>
<p><?php _e("Sorry, but you are looking for something that isn't here.","atahualpa"); ?></p>
just change the message to what you want
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
|
#6
Aug 30, 2011, 07:50 AM
|
|
Thanks a lot.
|
#7
Apr 27, 2012, 12:55 PM
|
|
So can just the upper code be used the create a custom 404 page and has the lower part then stripped from the index.php?
|
#8
May 10, 2012, 08:56 AM
|
|
|
|
45 posts · Oct 2009
Denmark
|
|
I have tried to make a 404.php but it don't show the styling of the pages.
Normally my pages shows like this http://www.torbenbendixen.dk/om/
But if I type an error page http://www.torbenbendixen.dk/hfdga it doesn't show like the normal pages.
What am I doing wrong?
I am using version 3.7.6
|
#9
May 10, 2012, 09:57 AM
|
|
|
|
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
|
|
the n'normal' pages are in a post div while your 404 page is not so the styling is not being set. I suggest you look at teh 'normal' page and see teh way the text is wrapped in a <div...>...</div> and add that to your code creating the 404
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
|
#10
May 10, 2012, 10:27 AM
|
|
|
|
45 posts · Oct 2009
Denmark
|
|
Thank you for this.
I am not sure what you mean by teh?
I have searched the forum for "normal page" but can't find something that can help me.
|
#11
May 10, 2012, 10:53 AM
|
|
|
|
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
|
|
by 'normal' I was refering to the page you used in the example, the way your pages 'normaly look.
The center area is made up of come divs that have classes and the classes are styled in the theme settings. Your 404 page does not have this div of teh clsasses so the styling is not applied.
You can add a new div and style it in the css options or
look at the code and see the existing div and classes and wrap your ode in it so the theme styling will apply.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
|
#12
May 11, 2012, 02:53 AM
|
|
|
|
45 posts · Oct 2009
Denmark
|
|
I see what you mean.
Thank you for this!!
I got it working now.
|
#13
May 17, 2012, 03:57 AM
|
|
Quote:
Originally Posted by freelancekonsulenten
I see what you mean.
Thank you for this!!
I got it working now.
|
Would you plese post what code you have used now in the end, I am having problems accomplishing this
|
#14
Jun 7, 2012, 02:14 PM
|
|
|
|
45 posts · Oct 2009
Denmark
|
|
First I use this plugin: http://wordpress.org/extend/plugins/useful-404s/
Then I create a file called 404.php, and put this code in the file:
<?php
/**
* for displaying 404 pages (Not Found).
**/
?>
<?php
list($bfa_ata, $cols, $left_col, $left_col2, $right_col, $right_col2, $bfa_ata['h_blogtitle'], $bfa_ata['h_posttitle']) = bfa_get_options();
get_header();
extract($bfa_ata);
?>
<div style="display: block; margin: 0 0 5px 0; padding: 10px 20px; background: white; -moz-border-radius: 10px; -khtml-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; border: solid 1px #E5E5E5;">
<?php
useful404s();
?>
</div>
<?php get_footer(); ?>
I then upload the 404.php file to the theme directory.
The code in the <div> should be the same code as your own design.
|
#15
Mar 26, 2016, 02:10 PM
|
|
Hi juggledad,
Thanks a lot for your help.
For better SEO purpose, I want to return a status 404 for soft 404 not found errors.
I tried to add redirection code in the else part of index.php but I failed with all the possible types of codes. Added a 404 page also. Could you please help me with this.
|
#16
Mar 26, 2016, 04:57 PM
|
|
|
|
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
|
|
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
|
#17
Mar 27, 2016, 11:19 AM
|
|
Hi,
I added the following code and the page is returning 404. Thanks for this.
else /* No posts */
<?php status_header( 404 ) ?>
<h2><?php _e('Not Found','atahualpa'); ?></h2>
<p><?php _e("Sorry","atahualpa"); ?></p>
I was actually trying to return the http status 404 and also redirect it to 404.php page. I could not do it.
|
#18
Mar 28, 2016, 04:37 AM
|
|
|
|
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
|
|
That will return a 404 - check your log - AND it will run a 404.php if you have one in the atahualpa folder. However it will show inside the atahualpa page you are building.
one other thing - a search for something that is not found will NOT generate a 404
if you create a link to a page that doesnot exist, that WILL create a 404
so a search for 'this-text-does-not-exist' will (probably) just return a not found (The text in index.php)
entering a url of http://yourdomani.com/this-text-does-not-exist should result in a 404 and what ever you have in your 404.php or the text in index.php.
if you want the 404 to redirect to a completly different page without your Atahualpa settings, you will probably need to add a 404 redirect in your htaccess file (if you don't know how - do a google search)
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
|