Skip to content

Instantly share code, notes, and snippets.

@jacks0n
jacks0n / wp-config.php
Created May 15, 2014 05:42
WordPress Any URL - A quick and dirty way of allowing WordPress to run on any URL, without having to replace URLs in the database. It will figure out the home URL, based on the current hostname and relative path from the server's root directory. It will also re-write existing links with the current site, using output buffering. eg. http://oldser…
// Add whatever URLs you want to replace with the current home URL
$replace_urls = array('http://exampleoldsite.com/mysite');
$uri = str_replace("{$_SERVER['DOCUMENT_ROOT']}/", '', dirname(__FILE__));
$home_url = sprintf('%s://%s/%s', $_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http', $_SERVER['SERVER_NAME'], $uri);
define('WP_SITEURL', $home_url); define('WP_HOME', $home_url);
function replace_old_urls($html) { global $replace_urls; return str_replace($replace_urls, WP_SITEURL, $html); }
ob_start('replace_old_urls');
@jacks0n
jacks0n / .htaccess
Created May 10, 2014 14:28
Default .htaccess
# Some sensible defaults
Options +FollowSymLinks -Indexes
AddDefaultCharset UTF-8
ServerSignature Off
# Hide sensitive information
RedirectMatch 404 /\.git
RedirectMatch 404 /*.sql
RedirectMatch 404 /Gruntfile.js
@jacks0n
jacks0n / .gitignore
Last active March 22, 2024 22:45
Comprehensive .gitignore
#######################################
# Operating Systems #
#######################################
# OS X
.DS_Store
._*
.Spotlight-V100
.Trashes