Project

General

Profile

1
RewriteEngine on
2
RewriteOptions AllowNoSlash InheritBefore
3

    
4
SetEnvIf Request_URI ^ innermost_dir=phpPgAdmin
5

    
6
# remove trailing / (not used)
7
RewriteRule ^(.*)/$ $1 [discardpath,noescape,qsappend]
8

    
9
# extract base URL
10
RewriteRule ^\[(.*)\](?:/(.*))?$ $2 [discardpath,noescape,qsappend,env=base_url:http://$1]
11

    
12
# extract path components 1st->last
13
#
14
# phpPgAdmin bug causes page to be ignored when not logged in. this is partially
15
# fixed by also specifying subject, which is not ignored. (however, when it
16
# falls back to using subject, it will go to the last selected tab, not the
17
# default, leftmost tab.)
18
#
19
# subject values @ /usr/share/phppgadmin/classes/Misc.php#getSubjectParams()
20
RewriteRule ^                          -                  [discardpath,noescape,qsappend,env=subject:root,env=page:servers]
21
RewriteRule ^([^/]+)(?:/(.*))?$        $2?server=$1       [discardpath,noescape,qsappend,env=subject:server,env=page:all_db]
22
RewriteRule ^([^/]+)(?:/(.*))?$        $2?database=$1     [discardpath,noescape,qsappend,env=subject:database,env=page:schemas]
23
RewriteRule ^([^/]+)(?:/(.*))?$        $2?schema=$1       [discardpath,noescape,qsappend,env=subject:schema,env=page:tables]
24
RewriteRule ^(views|functions)()$      $2                 [discardpath,noescape,qsappend,env=subject:schema,env=page:$1]
25
RewriteRule ^view=([^/]+)(?:/(.*))?$   $2?view=$1         [discardpath,noescape,qsappend,env=subject:view,env=page:viewproperties,env=action:columns]
26
RewriteRule ^fn.oid=([^/]+)(?:/(.*))?$ $2?function_oid=$1 [discardpath,noescape,qsappend,env=subject:function,env=page:functions,env=action:properties]
27
RewriteRule ^(columns|definition)()$   $2                 [discardpath,noescape,qsappend,env=action:$1]
28
RewriteRule ^([^/]+)(?:/(.*))?$        $2?table=$1        [discardpath,noescape,qsappend,env=subject:table,env=page:tblproperties]
29
RewriteRule ^([^/]+)(?:/(.*))?$        $2?column=$1       [discardpath,noescape,qsappend,env=subject:column,env=page:colproperties]
30

    
31
# custom pages
32
# must be in query string b/c .php filename would be treated as path element
33
RewriteCond %{QUERY_STRING} ^(?:.*&)?page=([^&]*)
34
RewriteRule ^ - [discardpath,noescape,qsappend,env=!subject,env=page:%1]
35

    
36
# redirect to now-constructed URL
37
# only append subject if non-empty, to avoid confusing redirect.php
38
RewriteCond %{ENV:base_url} !=""
39
RewriteCond %{ENV:subject} ="" [ornext]
40
RewriteCond ?subject=%{ENV:subject} ^(.*)$
41
RewriteRule ^$ %{ENV:base_url}/%{ENV:page}.php%1 [chain,discardpath,noescape,qsappend,redirect]
42
# append action
43
RewriteCond %{ENV:action} ="" [ornext]
44
RewriteCond ?action=%{ENV:action} ^(.*)$
45
RewriteRule ^.*$ $0%1 [discardpath,noescape,qsappend,redirect]
46

    
47
## for internal URLs
48

    
49
# auto-add trailing / (dir without trailing / is absolute filesystem path)
50
RewriteCond %{ENV:innermost_dir} =phpPgAdmin
51
RewriteRule ^/ %{REQUEST_URI}/ [discardpath,last,noescape,qsappend,redirect]
    (1-1/1)