Skip to content

Instantly share code, notes, and snippets.

View ianpegg's full-sized avatar

Ian Pegg ianpegg

View GitHub Profile
@ianpegg
ianpegg / .htaccess
Last active October 10, 2023 12:16
cPanel Web Root Rewrite: rewrite all traffic to go via 'web' directory
# ----------------------------------------------------------------------
# Rewrite all traffic to go via 'web' directory (Bedrock requirement)
# ----------------------------------------------------------------------
<IfModule mod_rewrite.c>
RewriteEngine On
# Adapted from: https://www.siteground.com/kb/how_to_change_my_document_root_folder_using_an_htaccess_file/
RewriteCond %{HTTP_HOST} ^example.(org.uk|test)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(staging|www).example.(org.uk|test)$
RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) /web/$1 [L]
@ianpegg
ianpegg / .editorconfig
Last active June 20, 2022 15:22
In-house document layout rules for EggCup Web Design Ltd.
## EditorConfig is awesome! ##
## https://EditorConfig.org ##
# Tutorial and examples:
# --> https://www.freecodecamp.org/news/how-to-use-editorconfig-to-standardize-code-styles/
# List of all possible properties:
# --> https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties
# This is the top-most EditorConfig file in this project:
@ianpegg
ianpegg / user-customizations.sh
Created May 13, 2022 13:54
Basic user customisation script for the Homestead virtual machine.
#!/bin/sh
# Set the default command line text editor:
sudo update-alternatives --set editor /usr/bin/vim.basic
# Set the default GIT push method:
git config --global push.default simple
# Set GIT user name and email in the global scope:
git config --global user.name "Your Name"
@ianpegg
ianpegg / .gitignore
Created May 13, 2022 13:51
.gitignore for WordPress & cPanel environment.
# -----------------------------------------------------------------
# .gitignore for WordPress
#
# This file is tailored for a WordPress project
# using the default directory structure
#
# This file specifies intentionally untracked files to ignore
# http://git-scm.com/docs/gitignore
#
# NOTES:
@ianpegg
ianpegg / .gitconfig
Created May 13, 2022 13:49
Basic gitconfig for local user profile.
[push]
default = simple
[user]
name = Your Name
email = you@example.com
[init]
defaultBranch = main
@ianpegg
ianpegg / .htaccess
Created April 15, 2022 11:30
Prevent search engines from indexing documents by file extension - useful for keeping promos secret
# ----------------------------------------------------------------------
# Prevent search engines from indexing documents by file extension - useful for keeping promos secret
# ----------------------------------------------------------------------
<IfModule mod_headers.c>
<FilesMatch "(\.(pdf|doc|docx|odt)|~)$">
Header set X-Robots-Tag "noindex, noarchive, nosnippet"
</FilesMatch>
</IfModule>
@ianpegg
ianpegg / index.php
Last active May 4, 2023 17:54
Intentionally empty index file to prevent directory listing on poorly configured servers.
<?php
/**
* Plugin Name: Empty Index File
* Plugin URI: https://gist.github.com/ianpegg/3a4ac333c3eeaed9309fa5dc6e9fa8c0
* Description: Prevents directory listing on mis-configured servers.
* Version: 1.0.0
* Author: Ian Pegg
* Author URI: https://eggcupwebdesign.com
* php version 7.4.15
<?php
/**
* Plugin Name: EggMUP: Suppress Site Status Tests
* Plugin URI: https://gist.github.com/ianpegg/cf7317ffbaf0714e1249d6f1deef97e5
* Description: Some site status tests are useful, but some are not.
* Version: 1.0.1
* Author: Ian Pegg
* Author URI: https://eggcupwebdesign.com
* Some site status report on matters that are not important, e.g.
* automatic updates being disabled when the site is under version control.
@ianpegg
ianpegg / disable-wp-cron.inc.php
Last active December 1, 2021 12:31
DISABLE_WP_CRON on its own does not prevent the wp-cron script from being executed via HTTP, meaning it is still vulnerable to exploitation by DDOS attacks. This script terminates any attempt to run wp-cron by any means other than the command line.
<?php
/**
* Plugin Name: EggMUP: Disable WP Cron
* Plugin URI: https://gist.github.com/ianpegg/36568e85cf692d3a901b475e4a14204e
* Description: Prevents wp-cron from being run via HTTP.
* DISABLE_WP_CRON on its own does not prevent the wp-cron script from being
* executed via HTTP, meaning it is still vulnerable to exploitation by DDOS attacks.
*
* Version: 1.0.0
* Author: Ian Pegg
<?php
/**
* Plugin Name: EggMUP: SEO Tools
* Plugin URI: https://gist.github.com/ianpegg/29d16c74fea470046c1dacb4f9dd3fb9
* Description: Tools for SEO tweaks.
* Version: 1.0.0
* Author: Ian Pegg
* Author URI: https://eggcupwebdesign.com
* php version 7.4.15