The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Command to upload 404 files to multiple domains.

Discussion in 'General Discussion' started by prettydumb, Aug 31, 2007.

  1. prettydumb

    prettydumb Active Member

    Joined:
    Aug 25, 2007
    Messages:
    35
    Likes Received:
    0
    Trophy Points:
    6
    When I set up my domains, several thousand of them, I did not include 404 error pages or robots.txt files. My logs show I should also be uploading favicons as well.

    I now know I should have set this up as I was entering the domain name into the system via root public_html.

    Is there a command you might share to have these files entered, without having to log into each separate account?

    Someone please throw a dummy a bone.
     
  2. verdon

    verdon Well-Known Member

    Joined:
    Nov 1, 2003
    Messages:
    836
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Northern Ontario, Canada
    cPanel Access Level:
    Root Administrator
    Look for fix404errors here - http://www.cplicensing.net/scripts.php

    I've modified copies of this for doing other things too, like robots.txt and fav icon files. I can share my modified versions if you're not able to make your own. The one mentioned above will look after your 404's though.
     
  3. prettydumb

    prettydumb Active Member

    Joined:
    Aug 25, 2007
    Messages:
    35
    Likes Received:
    0
    Trophy Points:
    6
    Can you tell me more about your modified script?

    Can you give me instructions on how to implement?
     
  4. verdon

    verdon Well-Known Member

    Joined:
    Nov 1, 2003
    Messages:
    836
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Northern Ontario, Canada
    cPanel Access Level:
    Root Administrator
    To use these, you need to login via ssh with a terminal/shell session. If you're not comfortable working in terminal a little bit, then you should get someone else to do it.

    I have a folder in my root dir with a few personal scripts like this one in it.

    So, I login via ssh and then...
    cd /root/scripts/

    then...
    sh fix404errors.pl


    To deal with missing favicons, I use the following script, in a file called 'fixfaviconerrors.pl' NOTE: For this to work, you must have a generic favicon file at /root/cpanel3-skel/public_html/favicon.ico which will get copied to any user public_html dir that doesn't already have one. You can easily modify this example for a basic robots.txt file too, or whatever your want.
    Code:
    #!/usr/bin/perl
    
    
    print "Starting Scan...\n";
    
    while(@USERS=getpwent()){
            if (-d "$USERS[7]/public_html") {
                    if (-f "$USERS[7]/public_html/favicon.ico") {
                            print "$USERS[0] favicon.ico exists\n";
                    } else {
                            print "$USERS[0] copying favicon.ico...";
                            use File::Copy;
                            copy("/root/cpanel3-skel/public_html/favicon.ico", "$USERS[7]/public_html/favicon.ico") or die "File cannot be copied.";
                            chmod(0644, "$USERS[7]/public_html/favicon.ico") or die "Unable to chmod file: $!";
                            chown($USERS[2],$USERS[3],"$USERS[7]/public_html/favicon.ico") or die "Unable to chown file: $!";
                            print "done\n";
                    }
            }
    }
    
    
    print "Scan Complete!\n";
    
    
    Good luck,
    verdon
     
Loading...

Share This Page