-
AuthorPosts
-
December 4, 2017 at 9:27 pm #884792
Dears,
I just stuck with the following question,- whilst the user is typing http://mydomain.com/jhjhkjhkjhkjhj trying to access the absent webpage, website must do the hard redirect to http://mydomain.com/404/ and show the content of 404.php
I know, there’re to many solutions there, but I didn’t found yet the right one.
Any idea of how to setup this either through .htaccess (APACHE) or something else?
December 6, 2017 at 10:45 am #885469Hey DimaP,
Here is a thread for you to consider
https://stackoverflow.com/questions/19962787/rewrite-url-after-redirecting-404-error-htaccess
and the Apache docs
http://httpd.apache.org/docs/2.2/custom-error.htmlIf you need further assistance please let us know.
Best regards,
VictoriaDecember 8, 2017 at 8:55 am #886384Hi, Victoria,
thanks for the suggestion. I just put the below lines into my .htaccess file, and seems it should work, as most suggestions in the web points to this code, but one doesn’t work – when user types something like http://mydomain.com/jhjhkjhkjhkjhj trying to access the absent webpage, website don’t do the hard redirect to http://mydomain.com/404/
Any idea of how to fix? Maybe something need to be done within the 404.php ?
ErrorDocument 404 http://mydomain.com/404/
RewriteEngine On
RewriteBase /RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ /wp-content/themes/enfold/404.php [L]December 9, 2017 at 11:14 pm #886993December 10, 2017 at 10:34 am #887073Hi,
404 page exists as a part of Enfold, and it is there, /wp-content/themes/enfold/404.phpBut the issue is that once the user types something wrong as e.g. http://mydomain.com/jhjhkjhkjhkjhj, and that page don’t exist, the browser redirects him to the http://mydomain.com/404/, showing this exact url also showing 404.php
In my case, browser shows 404.php indeed but not showing the http://mydomain.com/404/
December 11, 2017 at 3:34 am #887198Hi,
Ok, try creating a new page in WordPress and name it 404, and save. Be sure the url reads 404 and not 404-2 as mine did. I got past this point by naming it 4o4 (that is the letter o)
Then add this code to the end of your functions.php file in Appearance > Editor:function error_page_rewrite( $wp ) { if (is_404()) { wp_redirect( home_url( user_trailingslashit( '4o4' ) ) ); exit; } } add_action( 'wp', 'error_page_rewrite' );
*Note this has the 4 letter o 4 – change to suit you.
Now when you type jxjxjxjxj you will be sent to the 4o4 page and the url will only read http://www.yoursite.com/4o4/Best regards,
MikeDecember 11, 2017 at 6:51 pm #887535Thank you, Mike, everything is started to work as a charm! )
December 12, 2017 at 7:53 am #887775Hi,
Great, glad you got it working. Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardDecember 12, 2017 at 8:20 am #887784Hi, please close the ticket. Thank you.
-
AuthorPosts
- You must be logged in to reply to this topic.