Showing posts with label htaccess. Show all posts

Tutorial Different Directory Index Page

by in , 0

Normally index.html or index.php is the default page a server serves up when visiting a directory without specifying a file name. You can change this with .htaccess:

DirectoryIndex index2.html

Tutorial Append / Prepend Files

by in , 0

Rather than having to call / include a file you need on every single page, you can have them automatically prepended (top of file) or appended (bottom of file) automatically through your .htaccess file.

php_value auto_prepend_file "/real/path/to/file/functions.php"
php_value auto_append_file "/real/path/to/file/footer.php"

Tutorial Allow Single URL Through .htaccess Password Protection

by in , 0

This code is useful for multi environment setups (staging, production, etc.) it allows you to keep your htaccess files in sync while maintaining an htpasswd on your development environment or anything but the live environment.

#allows a single uri through the .htaccess password protection
SetEnvIf Request_URI "/testing_uri$" test_uri

#allows everything if its on a certain host
SetEnvIf HOST "^" testing_url
SetEnvIf HOST "^" live_url
Order Deny,Allow

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/your/.htpasswd
AuthGroupFile /
Require valid-user

#Allow valid-user
Deny from all
Allow from env=test_uri
Allow from env=testing_url
Allow from env=live_url
Satisfy any

Tutorial Active Gzip Compression

by in , 0

Compression reduces response times by reducing the size of the HTTP response. Gzip is the most popular and effective compression method currently available and generally reduces the response size by about 70%. Approximately 90% of today's Internet traffic travels through browsers that claim to support gzip.

<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript

Tutorial 301 Redirects

by in , 0

This is the cleanest way to redirect a URL. Quick, easy, and search-engine friendly. Remember HTAccess stuff is for Apache servers only.

Redirect a single page

Redirect 301 /oldpage.html
Redirect 301 /oldpage2.html

Redirect an entire site

This way does it with links intact. That is will become This is extremely helpful when you are just "moving" a site to a new domain. Place this on the OLD site:

Redirect 301 /