aboutsummaryrefslogtreecommitdiffstats
path: root/railties/configs/apache.conf
blob: 5548292f8d5f3a64252ab5f894fad2693a863f27 (plain) (blame)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# General Apache options
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI

# Make sure that mod_ruby.c has been added and loaded as a module with Apache
RewriteEngine On

# Change extension from .cgi to .fcgi to switch to FCGI and to .rb to switch to mod_ruby
RewriteBase /dispatch.cgi

# Enable this rewrite rule to point to the controller/action that should serve root.
# RewriteRule ^$ /controller/action [R]

# <caching>
# no query string?
RewriteCond %{QUERY_STRING} ^$

# no POST method? 
RewriteCond %{REQUEST_METHOD} !^POST$ [NC]

# Request filename is a directory?
RewriteCond %{REQUEST_FILENAME} -d

# Request filename + '/index' is a file?
RewriteCond %{REQUEST_FILENAME}/index -f

# Rewrite to request filename + '/index' and finish
RewriteRule ^(.*)/?$ $1/index [QSA,L]

# no query string?
RewriteCond %{QUERY_STRING} ^$

# no POST method?
RewriteCond %{REQUEST_METHOD} !^POST$ [NC]

# Request filename is a file?
RewriteCond %{REQUEST_FILENAME} -f

# Finish rewriting
RewriteRule .* - [L]

# Set default type of cached files to text/html
DefaultType text/html
# </caching>

# Add missing slash
RewriteRule ^([-_a-zA-Z0-9]+)$                                            /$1/ [R]

# Default rewriting rules. 
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([0-9]+)$                  ?controller=$1&action=$2&id=$3 [QSA,L]
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$                           ?controller=$1&action=$2 [QSA,L]
RewriteRule ^([-_a-zA-Z0-9]+)/$                                           ?controller=$1&action=index [QSA,L]

RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([0-9]+)$ ?module=$1&controller=$2&action=$3&id=$4 [QSA,L]
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$          ?module=$1&controller=$2&action=$3 [QSA,L]
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/$                          ?module=$1&controller=$2&action=index [QSA,L]

# You can also point these error messages to a controller/action
ErrorDocument 500 /500.html
ErrorDocument 404 /404.html