Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save michaeltroy/303867 to your computer and use it in GitHub Desktop.
Save michaeltroy/303867 to your computer and use it in GitHub Desktop.
# When developing a static website we want to deploy two copies. The
# first is the staging copy and the second is the live production copy.
# The staging copy will be deployed to the following directory:
# 'http://website.com/development/current/index.php'
# The production copy will be deployed to the following directory:
# 'http://website.com/home/current/index.php'
# The directory paths need to be rewritten like so:
# 'http://website.com/development/current/index.php' should now look like
# 'http://website.com/development/'
# 'http://website.com/home/current/index.php' should now look like
# 'http://website.com'
# Note: 'current' is a symlinked directory.
# so far I have the production copy working correctly but not development.
# ------------------------------------------------------------------------#
RewriteEngine On
# Remove the www
RewriteBase /
RewriteCond %{HTTP_HOST} !^website.com$ [NC]
RewriteRule ^(.*)$ http://website.com/$1 [L,R=301]
# Rewrite 'home/current/' to 'website.com'
RewriteCond %{HTTP_HOST} ^website.com$
RewriteCond %{REQUEST_URI} !^/home/current/
RewriteRule (.*) /home/current/$1
# 404 redirect
ErrorDocument 404 /404.php
# ------------------------------------------------------------------------#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment