Skip to content

Instantly share code, notes, and snippets.

@leowebguy
leowebguy / .htaccess
Last active June 10, 2016 19:19
full htaccess file for wordpress developers | password request, redirect, specific files protection, no directory browsing, prevent php execution, mod_cache, mod_mime, etag, mod_expires, mod_deflate, gzip
# Change [/home/public_html/yourwebsite/] to your absolute path
# Create a .htpasswd file
# Add guest:/ls2opk3b1puY >> login: guest | pw: guest
AuthUserFile /home/public_html/yourwebsite/.htpasswd
AuthName "Type Password"
AuthType Basic
Require valid-user
<IfModule mod_rewrite.c>
RewriteEngine On
@andhiermawan
andhiermawan / minify_html.php
Last active February 7, 2018 03:59
Minify HTML Wordpress: Include in wp_head!
// Minify HTML on The Fly Wordpress
// http://ermawan.com/php-minify-html-on-the-fly
function minify_html($buffer) {
$search = array(
'/\>[^\S ]+/s', // strip whitespaces after tags, except space
'/[^\S ]+\</s', // strip whitespaces before tags, except space
'/(\s)+/s' // shorten multiple whitespace sequences
);
$replace = array(
'>',
@jasperf
jasperf / block-php-execution
Created March 12, 2015 10:56
Block PHP Execution in Folder #wordpress #security
<Files *.php>
deny from all
</Files>
@webaware
webaware / htaccess-extras
Last active November 6, 2025 04:29
Here’s some basic recipe stuff to put into the top of .htaccess, above WP Super Cache and WordPress rules. Together, they reduce load on the server by compressing static files before sending them, making browsers cache static files, dying quickly on static files 404 errors, and blocking some common hacker / spammer attacks.
# v19 2025-11-06
# prevent listing files in folders
Options -Indexes
# some security rules
<IfModule mod_rewrite.c>
RewriteEngine On
# prevent php execution in uploads
RewriteRule /uploads/.*\.php - [F]
<?php
class WP_HTML_Compression {
protected $compress_css = true;
protected $compress_js = true;
protected $info_comment = true;
protected $remove_comments = true;
protected $html;
public function __construct($html) {
if (!empty($html)) {
@simplethemes
simplethemes / minify-theme.php
Created January 17, 2013 05:12
minify WordPress theme styles.
/*-----------------------------------------------------------------------------------*/
// Register and Minify Core Stylesheets
/*-----------------------------------------------------------------------------------*/
function st_registerstyles() {
// minify folder name (must be in your wp root).
$minpath = '/min';
// define directories
$child_theme = str_replace(site_url().'/wp-content/themes/', '', get_bloginfo('stylesheet_directory'));
@neo22s
neo22s / seoreport.php
Created August 19, 2012 08:59
seo report php
<?php
/**
*
* SEO report for different metrics
*
* @category SEO
* @author Chema <chema@garridodiaz.com>
* @copyright (c) 2009-2012 Open Classifieds Team
* @license GPL v3
* Based on seo report script http://www.phpeasycode.com && PHP class SEOstats