Sharing .htaccess rules

Overview An .htaccess file may be shared across multiple domains and subdomains by being located in a common parent directory. Locating an .htaccess under /var/www will allow any domain or subdomain located under /var/www to inherit these rules; effectively any domain or subdomain that is not managed by a secondary user within that user’s respective…

Passenger applications do not inherit htaccess rules

Overview .htaccess files are used to control behaviors of applications by overriding global server configuration. Any Passenger-based application, which includes Node, Python, and Ruby, will stop processing rules beyond the document root, often noted by convention as public/. Cause Passenger is managed by a separate facility that immediately takes control of the request once Apache detects that the…

Enabling Google Analytics support

Overview Google Analytics is a free web analytics application provided by Google, including SEO recommendations and live site traffic. Setting up GA Google Analytics can be enabled on newer, v5+ platforms using two lines in a .htaccess file. Visit Google Analytics to create a profile for the domain Once the profile is created, you will see sample code to insert:…

Adding pretty-print URLs

Overview Pretty-print URLs (permalinks) in WordPress transform meaningless URL patterns, e.g. index.php?page_id=123 into meaningful URLs, like /wordpress/adding-pretty-print-urls. Navigation is easier to view in the browser, plus it helps with SEO. Enabling pretty-print is a two-part process, add a few lines to your .htaccess and configure the display style in WordPress. Solution Create a .htaccess file inside the document root for your…

Rewrite rules fail on subdirectories, subdomains, or addon domains

Overview Rewrite rules remap a URL to another location or resource accessible on a web site. These rules are located in .htaccess files. A common snippet looks similar to: RewriteEngine On RewriteCond %{REQUEST_FILENAME} ! -f RewriteRule ^(.*)$ index.php [QSA, L] When located anywhere else besides the document root of the primary domain name, rewrite rules will…

.htaccess Guide

Overview An .htaccess file contains directives that the web server will apply to a collection of resources before a page is displayed. For example, a .htaccess file may change PHP configuration, deny access, change the page displayed, and even redirect a resource to another URL. These are denoted by a directive. A directive consists of a directive…

Forcing HTTP redirect to SSL

Overview Converting HTTP to HTTPS resources can be accomplished in several ways. It goes without saying that you should setup and test your SSL certificate before performing any of the following methods. Strict Transport Security Modern browsers support a security standard called “HTTP Strict Transport Security“, or HSTS for short. HSTS sends a header with…

Changing PHP settings

Overview Certain default PHP settings may be insufficient for an application. For example, it may be necessary to accept large file uploads or display errors on-screen to facilitate rapid prototyping during early stages of an application. Solution PHP settings may be changed 2 ways, each with varying scope. All settings except for open_basedir and memory_limit may be adjusted.…