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.

Cron Job to replace .htaccess

Discussion in 'General Discussion' started by metrocard, Oct 20, 2010.

  1. metrocard

    metrocard Registered

    Joined:
    Oct 20, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    So, I have a huge .htaccess file to block all non-US IPs. (This is the only way I can do this since I'm on shared hosting and can't do IP tables)

    The downside to using .htaccess is that a huge one slows down the site. I would like to make a cron job that replaces the .htaccess file with with a different one during the night and then replace that one with the original in the morning. This way, the site is only slowed down during the night when there aren't many people on. (My site is targeted towards a small group of people and having it open to the entire world just opens the site up to spam)

    For example
    /Folder1/.htacess <-- with IP block
    /Folder2/.htacess <-- without IP block
    /.htacess <-- current .htaccess without IP block.

    At 12:00 AM, it copies the .htaccess from Folder1 and replaces the one in the root directory. Then at 8:00 AM, it copies the .htaccess from Folder2 to replace the one in the root.

    Is this possible? If it is, can someone help me achieve this?
     
Loading...

Share This Page