How to force Apache to use manually pre-compressed gz file of CSS and JS files?

Some RewriteRule should handle that quite well. In a Drupal configuration file I found: # AddEncoding allows you to have certain browsers uncompress information on the fly. AddEncoding gzip .gz #Serve gzip compressed CSS files if they exist and the client accepts gzip. RewriteCond %{HTTP:Accept-encoding} gzip RewriteCond %{REQUEST_FILENAME}\.gz -s RewriteRule ^(.*)\.css $1\.css\.gz [QSA] # Serve … Read more

Configuring MAMP for SSL

If you’re using MAMP 3 or 4 the instructions are slightly different. Here’s what worked for me, starting from a fresh install of MAMP 3.0.5 on Mavericks without Pro. Update: Still works on Yosemite after fixing Apache as described in this answer. Further Update: Comments suggest this still works at least through MAMP 5.4. Generate … Read more

File Caching: Query string vs Last-Modified?

TL;DR Why do so many websites use the “query string” method, instead of just letting the last-modified header do its work? Changing the query string changes the url, ensuring content is “fresh”. Should I unset the Last-modified header and just work with query strings? No. Though that’s almost the right answer. There are three basic … Read more

php hide ALL errors [duplicate]

PHP has a configuration directive intended exactly for that, called display_errors. Like any other configuration setting, it’s best to be set in php.ini. But in case you don’t have access to this file, you can set it right in PHP code to Hide All Errors: ini_set(‘display_errors’, 0); to Show All Errors: ini_set(‘display_errors’, 1); While ERROR_REPORTING … Read more

htaccess exclude one url from Basic Auth

Using SetEnvIf, you can create a variable when the request starts with some path, then use the Satisfy Any directive to avoid having to login. # set an environtment variable “noauth” if the request starts with “/callbacks/” SetEnvIf Request_URI ^/callbacks/ noauth=1 # the auth block AuthName “Please login.” AuthGroupFile /dev/null AuthType Basic AuthUserFile /xxx/.htpasswd # … Read more