middlebury/GO/master/.htaccess - Htaccess File

middlebury/GO/master/.htaccess

##
# Requires Apache2 with mod_rewrite
#
# The general idea with re-writing GO URLs is that for files and directories
# that exist (such as scripts.js, styles.css, update.php, etc) we want to 
# respond with the file at that path. For all other cases (where no file or
# directory exists) we assume that the requested path is a GO shortcut and
# internally rewrite the path to go to redirect.php which will then lookup the
# destination (if any) for the shortcut and send the user appropriate redirect
# headers.
#
# Note: These directives can be placed in the httpd.conf as well. If serving
# separate sets of shortcuts for different institutions out of the same code
# directory (via Apache VHosts), it is preferable to place these directives in
# each vhost.conf so that the institution parameters can be set appropriately.
##
RewriteEngine On

# Set this to the path of your GO instalation.
RewriteBase /

##
# mod_rewrite handles the query-string portion of requests separately from the
# rest of the path. Since we need to include the query string directly in the
# 'code' parameter that we are passing to redirect.php, we need have slightly 
# different handling if the path includes a query string so as to not include a
# bogus '?' in the code if no query is present, and to include it if there is a 
# query present.
##

# Case where there IS a query string
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} !^$
RewriteRule ^(.*)/? redirect.php?code=$1?%{QUERY_STRING} [L]

# Case where there IS NOT a query string
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/? redirect.php?code=$1 [L]

On Github License

Files

Download PDF of Htaccess file
QUERY_STRING, REQUEST_FILENAME

Comments

Apache