-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.htaccess.example
executable file
·45 lines (40 loc) · 1.88 KB
/
.htaccess.example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
##
# 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 installation.
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]
# If we don't have a full host-name, bump out the the full hostname.
# Replace "go.middlebury.edu" with your application's hostname.
RewriteCond %{HTTP_HOST} ^go$ [NC]
RewriteRule (.*) http://go.middlebury.edu/$1 [L,R,QSA]