WordPress.org

Ready to get started?Download WordPress

Forums

How do I create coding for a 404 Error page????? (2 posts)

  1. irishgem
    Member
    Posted 1 year ago #

    Below is the .htaccess coding I am using currently. My site was created by someone else and I am just editing it.

    I am using pages only (no posts or blog). I had used this domain previous with several pages (not on WordPress). Those are now being picked up by Google still even though they are not active. I want to make sure that ONLY the current pages are picked up.

    Right now when you type in http://www.domainname.com/HJDKAJSDA or anything after the forward slash, it's bringing up the layout of my site with "Page Not Available." I want it to go to a 404 Error page instead (that I will create.

    Could someone PLEASE look at this coding and see what I need to fix or change. I KNOW how to create a 404 error page, but I just dont understand this coding. THANK YOU!!!!

    # BEGIN Better WP Security
    Options -Indexes

    Order allow,deny
    Allow from all
    Deny from 50.57.148.24
    <files .htaccess>
    Order allow,deny
    Deny from all
    </files>

    <files readme.html>
    Order allow,deny
    Deny from all
    </files>

    <files readme.txt>
    Order allow,deny
    Deny from all
    </files>

    <files install.php>
    Order allow,deny
    Deny from all
    </files>

    <files wp-config.php>
    Order allow,deny
    Deny from all
    </files>

    <IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^wp-admin/includes/ - [F,L]
    RewriteRule !^wp-includes/ - [S=3]
    RewriteCond %{SCRIPT_FILENAME} !^(.*)wp-includes/ms-files.php
    RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
    RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
    RewriteRule ^wp-includes/theme-compat/ - [F,L]

    RewriteCond %{REQUEST_METHOD} ^(TRACE|DELETE|TRACK) [NC]
    RewriteRule ^(.*)$ - [F,L]

    RewriteCond %{REQUEST_METHOD} POST
    RewriteCond %{REQUEST_URI} ^(.*)wp-comments-post\.php*
    RewriteCond %{HTTP_REFERER} !^(.*)domainname.com.*
    RewriteCond %{HTTP_REFERER} !^http://jetpack\.wordpress\.com/jetpack-comment/ [OR]
    RewriteCond %{HTTP_USER_AGENT} ^$
    RewriteRule ^(.*)$ - [F,L]

    RewriteCond %{QUERY_STRING} \.\.\/ [NC,OR]
    RewriteCond %{QUERY_STRING} ^.*(bash|git|hg|log|svn|swp|cvs) [NC,OR]
    RewriteCond %{QUERY_STRING} etc/passwd [NC,OR]
    RewriteCond %{QUERY_STRING} boot\.ini [NC,OR]
    RewriteCond %{QUERY_STRING} ftp\: [NC,OR]
    RewriteCond %{QUERY_STRING} http\: [NC,OR]
    RewriteCond %{QUERY_STRING} https\: [NC,OR]
    RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
    RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|%3D) [NC,OR]
    RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [NC,OR]
    RewriteCond %{QUERY_STRING} ^.*(\[|\]|\(|\)|<|>|ê|"|;|\?|\*|=$).* [NC,OR]
    RewriteCond %{QUERY_STRING} ^.*("|'|<|>|\|{||).* [NC,OR]
    RewriteCond %{QUERY_STRING} ^.*(%24&x).* [NC,OR]
    RewriteCond %{QUERY_STRING} ^.*(%0|%A|%B|%C|%D|%E|%F|127\.0).* [NC,OR]
    RewriteCond %{QUERY_STRING} ^.*(globals|encode|localhost|loopback).* [NC,OR]
    RewriteCond %{QUERY_STRING} ^.*(request|select|concat|insert|union|declare).* [NC]
    RewriteCond %{QUERY_STRING} !^loggedout=true
    RewriteCond %{QUERY_STRING} !^action=rp
    RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in_.*$
    RewriteRule ^(.*)$ - [F,L]

    </IfModule>
    # END Better WP Security

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

  2. shawncbarry
    Member
    Posted 1 year ago #

    If I misunderstood your question, ignore this post, but it SOUNDS like you just want a custom 404, not the WP default.

    That "Page not found" is coming from your WordPress 404 page, 404.php inside your theme files. So, you just need to edit that page to be whatever you want. That htaccess code (I don't know much about htaccess code either, but I recognize some of it) is simply setting up some re-write rules based on different conditions. But, if you just edit the 404.php page, then you're set.

    Is that what you're asking?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.