WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Using .htaccess for ErrorDocument 404 redirect for Multisite network (9 posts)

  1. toniM07
    Member
    Posted 1 year ago #

    Hi
    Just resolved how to use 301 redirects for Multi site by using RewriteCond for each domain and then individual RewriteRules

    Example
    RewriteCond %{HTTP_HOST} ^domain-two\.com [nc]
    RewriteRule ^oldfile.htm http://domain-one.com/new-file/ [L,R=301]

    RewriteCond %{HTTP_HOST} ^domain-three\.com [nc]
    RewriteRule ^oldfile.htm http://domain-one.com/new-file/ [L,R=301]

    Now I would like to setup a universal ErrorDocument 404 that redirects to the primary multisite domain home page http://domain-one.com/

    I have tried various scenarios but keeps redirecting to the theme 404.php which should not be changed as it will be overwritten each time the theme is updated

    Suggestions appreciated. Thanks.

  2. All 404's redirect to domain-one.com?

    http://www.htaccessbasics.com/404-custom-error-page/

  3. toniM07
    Member
    Posted 1 year ago #

    Ideally all 404 errors would redirect to the primary network site's home page as the 301 redirects take care of old pages to new pages. The 404 redirect is the final catchall.

    Am using Genesis framework with child theme. Genesis has the 404.php in the main Genesis theme directory with strict instructions not to make any edits.

    I made a customized version of the file, put it in the wp-content directory and used ErrorDocument 404 /wp-content/404.php
    but redirect keeps going to the 404.php in the Genesis theme directory

  4. What if you do

    ErrorDocument 404 http://domain-one.com
  5. toniM07
    Member
    Posted 1 year ago #

    I tried that.
    Still goes to the Genesis parent theme 404.php file

    Example of none existing page without 301 redirect
    http://catalyticovens.com/applicons/

    I put
    ErrorDocument 404 http://catalyticovens.com
    after all the 301 Redirects and before # BEGIN WordPress

  6. In retrospect, yes.

    http://catalyticovens.com/applicons/ isn't a real 404, it's being parsed by WordPress because http://catalyticovens.com/ exists.

    Edit the 404.php in your child theme to redirect people instead of showing them the 404 page. WP is handling the error, like it's supposed to.

  7. toniM07
    Member
    Posted 1 year ago #

    Problem is, there is no 404.php in the child theme directory. Only the parent theme directory. As I noted above:
    _________________________
    Am using Genesis framework with child theme. Genesis has the 404.php in the main Genesis theme directory with strict instructions not to make any edits.

    I made a customized version of the file, put it in the wp-content directory and used ErrorDocument 404 /wp-content/404.php
    but redirect keeps going to the 404.php in the Genesis theme directory
    ____________________________

    So I am thinking any edits I make to the parent theme 404.php (which they ask you not to do) will be overwritten each time there is a theme update...?

  8. Problem is, there is no 404.php in the child theme directory. Only the parent theme directory.

    ...

    So make one?

    So I am thinking any edits I make to the parent theme 404.php (which they ask you not to do) will be overwritten each time there is a theme update...?

    Copy 404.php from the parent to the child. Edit there. Drink beer :)

  9. toniM07
    Member
    Posted 1 year ago #

    thank you. so obvious when you sit back (and drink a beer, or in my case glass of wine).

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.