Skip to content

Instantly share code, notes, and snippets.

@Javvadilakshman
Last active August 29, 2015 14:18
Show Gist options
  • Select an option

  • Save Javvadilakshman/3de06f94b1a6a76571cb to your computer and use it in GitHub Desktop.

Select an option

Save Javvadilakshman/3de06f94b1a6a76571cb to your computer and use it in GitHub Desktop.
.htacces Snippets

List of .htaccess Snippets

RewriteEngine On
DirectoryIndex index.php

One of the lessor known and used capabilities of .htaccess files is the ability to prepend and append includes to every page request. Doing so avoids needing to code in every template file you wat to use them in. Here's the .htaccess code:

<?php require('footer.php'); ?>

Prepend the file

php_value auto_prepend_file "/dir/path/utilities.php"

Append file to bottom of page

php_value auto_append_file "/dir/path/templates/footer.php"

RewriteEngine On

RewriteCond %{HTTP_HOST} ^demos.9lessons.info$ RewriteCond %{REQUEST_URI} !^/demos/ RewriteRule (.*) /demos/$1

RewriteEngine On

RewriteCond %{HTTP_HOST} ^labs.9lessons.info$ RewriteCond %{REQUEST_URI} !^/labs/ RewriteRule (.*) /labs/$1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment