forked from delta/pragyan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
htaccess-dist-cgi
138 lines (116 loc) · 6.13 KB
/
htaccess-dist-cgi
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
##########################GENERAL CONFIGURATION###########################
Options +FollowSymLinks
#REWRITEENGINE
RewriteEngine Off
IndexIgnore *
##Disable showing of ~ files and python scripts
<FilesMatch ".*(~|#|py)$">
Order allow,deny
Deny from all
</FilesMatch>
####################END OF GENERAL CONFIGURATION##########################
####################REWRITE RULE CONFIGURATION############################
#AIM : To convert
# http://pragyan.org/directory1/home/events/dalalstreet+admin_edit?uid=2004&page=2
# to : http://pragyan.org/direcityr1/index.php?page=home/events/dalalstreet&action=admin_edit&uid=2004&page=2
# (Can't be done )
# So doing this : http://pragyan.org/directory1/home/events/dalalstreet+admin_edit&uid=2004&page=2
# To : http://pragyan.org/directory1/index.php?page=home/events/dalalstreet&action=admin_edit&uid=2004&page=2
#
# Rules
# Get vars are passed directly by &a=b&c=d (no ? in the beginning)
# Actions are specified like this : http://localhost/workspace2/pragyan_v2/home/page1/+view
# Example :
# For the page /event/ventura/register action: register getVariables:uid=1,gid=2,reload=1
# , the url would be : #
# http://pragyan.org/CMSROOTDIR/home/event/ventura/register/+register&uid=1&gid=2&reload=1
##Tell rewriterule the current directory :#######
############################################################################
####CHANGE THE FOLLOWING LINES ACCORDING TO YOUR RewriteBase################
####Eg: /workspace2/pragyan_v2 is RewriteBase for http://localhost/workspace2/pragyan_v2/home/a/+b&a=34
#### or assuming the directory where this file is kept is webserverRoot/workspace6/pragyan_v2
#BASEDIRECTORY
############################################################################
##The previous rewritecond is there because the -d option even disables the current directory
##But we want the current directory to also to convert to something/home/something
RewriteRule ^(.*)$ home/$1 [R,L]
##To put /home in each request###################
#If the requested path is not file, and so is directed the cms only, then make sure that /home is the root path.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^(.*)/home(.*)$
RewriteCond %{REQUEST_URI} !^(.*)/user:(.*)$
RewriteCond %{REQUEST_URI} !^(.*)/index.php(.*)$
RewriteRule ^(.*)$ home/$1 [R,L]
##To put trailing slash after page so links work fine
# pragyan/home/a to pragyan/home/a/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^(.*)/user:(.*)$
RewriteCond %{REQUEST_URI} ^([^+?&]+[^/])$
RewriteCond %{REQUEST_URI} !^([^+?&]+\.(css|gif|png|jpe?g|js|html|xml|pdf|doc|docx|ods|odt|oft|pps|ppt|pptx|avi|txt|std|stc|sti|stw|svgz?|sxc|sx.|tex|tiff|txt|chm|mp3|mp2|wave?|ogg|mpe?g|wmv|wma|wmf|rm|avi|gzip|gz|rar|bmp|psd|bz2|tar|zip|swf|fla|flv|eps|ico|xcf|m3u|lit|bcf|xls|mov|xlr|exe|7?z))$ [NC]
RewriteRule ^([^+?]+[^/])$ $1/ [R,L]
# pragyan/home/a&a=b&c=d to pragyan/home/a/&a=b&c=d
RewriteCond %{REQUEST_URI} ^([^+?&]+[^/])&(.*)$
RewriteRule ^([^+?&]+[^/])&(.*)$ $1/&$2 [R,L]
# pragyan/home/a+view&a=b&c=d to pragyan/home/a/+view&a=b&c=d
RewriteCond %{REQUEST_URI} ^([^+]+[^/])[+]([^+]*)$
RewriteRule ^([^+]+[^/])[+]([^+]*) $1/+$2 [R,L]
##Home : name of root page
# pragyan.org/.../home/a/b/ to pragyan.org/.../index.php/a/b/ internally (not redirecting)
RewriteCond %{REQUEST_URI} ^(.*)home/(.*)$
RewriteRule ^(.*)home(.*)$ $1index.php$2
##User profile page
RewriteCond %{REQUEST_URI} ^(.*)user:(.*)$
RewriteRule ^(.*)user:(.*)$ $1index.php?user=$2
##Case 0 : The requested page is a file for file module
# pragyan.org/.../index.php/a/b/xxx.jpg to pragyan.org/.../index.php?page=/a/b/&file=xxx.jpg
RewriteCond %{REQUEST_URI} ^(.*)index.php([^+?&]+\.(css|gif|png|jpe?g|js|html|xml|pdf|doc|docx|ods|odt|oft|pps|ppt|pptx|avi|txt|std|stc|sti|stw|svgz?|sxc|sx.|tex|tiff|txt|chm|mp3|mp2|wave?|ogg|mpe?g|wmv|wma|wmf|rm|avi|gzip|gz|rar|bmp|psd|bz2|tar|zip|swf|fla|flv|eps|ico|xcf|m3u|lit|bcf|xls|mov|xlr|exe|7?z))$ [NC]
RewriteRule ^(.*)index.php(.*)/([^/]+)$ $1index.php?page=$2/&fileget=$3 [L]
##Case 1 : no action given
# pragyan.org/.../index.php/a/b/ to pragyan.org/.../index.php?page=/a/b/
RewriteCond %{REQUEST_URI} ^(.*)index.php([^+]+)$
RewriteRule ^(.*)index.php([^+]+)$ $1index.php?page=$2 [L]
##Case 2 : action given
# pragyan.org/.../index.php/a/b/+view to pragyan.org/.../index.php?page=/a/b/&action=view
RewriteCond %{REQUEST_URI} ^(.*)index.php([^+]*)\+([^+]*)$
RewriteRule ^(.*)index.php([^+]*)\+([^+]*)$ $1index.php?page=$2&action=$3 [L]
####################END OF REWRITE RULE CONFIGURATION#####################
####ALL CHANGES FROM THIS POINT ONWARDS ARE NOT NECESSARY#################
##To disable www ################################
#RewriteCond %{HTTP_HOST} ^pragyan$ [NC,OR]
#RewriteCond %{HTTP_HOST} ^www.pragyan.org$ [NC]
#RewriteRule ^(.*)$ http://pragyan.org/$1 [R=301,L]
############Following added to httpd.conf to make home directories work: #
##To prevent access to files ~something.html and #something.html#
#<Files ~ "(.*(~|#)$)">
# Order allow,deny
# Deny from all
#</Files>
##To show public_html access
# RewriteEngine On
# RewriteCond %{REQUEST_URI} ^/~\w+/.*$
# RewriteRule /~(\w+)/(.*) /webteam/$1/public_html/$2
# RewriteCond %{REQUEST_URI} ^/~\w+$
# RewriteRule /~(\w+) /webteam/$1/public_html/
##To enable .htaccess rules in public_html
#<Directory /webteam/*/public_html>
# AllowOverride All
#</Directory>
#
#Also make "AllowOverride All" in the <Directory /var/www/html> Section
# Other optimization changes :
# MaxKeepAliveRequests 200
#
#
#TO PREVENT LEECHING OF IMAGES
#RewriteEngine on
#
#RewriteCond %{HTTP_REFERER} !^$
#RewriteCond %{HTTP_REFERER} !^http://www.pragyan.org/.*$ [NC]
#RewriteCond %{HTTP_REFERER} !^http://pragyan.org/.*$ [NC]
#RewriteCond %{HTTP_REFERER} !^http://pragyan(.org)?/.*$ [NC]
#RewriteCond %{HTTP_REFERER} !^http://10.0.0.125/.*$ [NC]
#RewriteCond %{HTTP_REFERER} !^http://203.129.195.143/.*$ [NC]
#RewriteRule .*.(gif|jpe?g|png)$ http://www.pragyan.org/accessdenied.jpg [NC,L]
#<== The file that we want to display rather
#