Repository navigation
Expand file tree
/
Copy path.htaccess
More file actions
173 lines (142 loc) · 7.27 KB
/
Copy path.htaccess
File metadata and controls
173 lines (142 loc) · 7.27 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
ErrorDocument 401 /errors/401.html
ErrorDocument 403 /errors/403.html
ErrorDocument 404 /errors/404.html
ErrorDocument 500 /errors/500.html
ErrorDocument 501 /errors/501.html
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
## NO DEBEN EDITAR ESTO, YA QUE PUEDE GENERAR ERROR! DEBE TENER LAS LINEAS 12 HASTA 15
#RewriteBase /
#RewriteCond %{SERVER_PORT} 80
#RewriteCond %{HTTP_HOST} ^http://TU_SITIO_WEB.com[NC,OR]
#RewriteRule ^(.*)$ https://TU_SITIO_WEB.com/$1 [L,R=301,NC]
Options +FollowSymLinks
# Protege contra escaneos y manipulaciones malintencionadas
RewriteCond %{HTTP_USER_AGENT} ^$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^(-|\.|') [OR]
RewriteCond %{HTTP_USER_AGENT} ^(.*)(<|>|%3C|%3E)(.*) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(java|curl|wget)(.*) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(.*)(libwww-perl|libwwwperl|snoopy|curl|wget|winhttp|python|nikto|scan|clshttp|archiver|loader|email|harvest|fetch|extract|grab|miner|suck|reaper|leach)(.*) [NC,OR]
RewriteCond %{REQUEST_URI} ^(/,|/;|/<|/>|/'|/`|/%2C|/%3C|/%3E|/%27|/////) [NC,OR]
RewriteCond %{HTTP_REFERER} ^(.*)(%00|%08|%09|%0A|%0B|%0C|%0D|%0E|%0F|%2C|<|>|'|%3C|%3E|%26%23|%27|%60)(.*) [NC,OR]
RewriteCond %{QUERY_STRING} ^(.*)(%00|%08|%09|%0A|%0B|%0C|%0D|%0E|%0F|%2C|%3C|%3E|%27|%26%23|%60)(.*) [NC,OR]
RewriteCond %{QUERY_STRING} ^(.*)('|-|<|>|,|/|\\|\.a|\.c|\.t|\.d|\.p|\.i|\.e|\.j)(.*) [NC,OR]
RewriteCond %{HTTP_COOKIE} ^(.*)(<|>|'|%3C|%3E|%27)(.*) [NC]
## Evitar que se liste el contenido de los directorios
Options All -Indexes
IndexIgnore *
# Limitar tama?o de subida de archivos
LimitRequestBody 10240000
# Denegando acceso a estas carpetas
RewriteRule ^(vendor|config|storage|app|logs) - [F,L]
# INDEX
RewriteRule ^$ index.php?do=home [QSA,L]
RewriteRule ^mi/$ index.php?do=portal [QSA,L]
RewriteRule ^pagina([0-9]+)$ index.php?page=$1 [QSA,L]
RewriteRule ^index.php$ index.php?do=home [QSA,L]
RewriteRule ^cuenta/([A-Za-z0-9_-]+)$ App/Controller/cuenta.php?accion=$1 [QSA,L]
RewriteRule ^status.html$ App/Controller/status.php [QSA,L]
# CALLBACK PARA REDES SOCIALES
RewriteRule ^(github|discord|google|facebook|reddit)\.php$ App/Callback/$1.php [QSA,L]
RewriteRule ^(migrator|seed)/$ app/database/$1.php [QSA,L]
#PERFIL
RewriteRule ^perfil/([A-Za-z0-9_-]+)(/([0-9]+))?$ App/Controller/perfil.php?user=$1&pid=$3 [QSA,L]
RewriteRule ^@([A-Za-z0-9_-]+)(/([0-9]+))?$ App/Controller/perfil.php?user=$1&pid=$3 [QSA,L]
# POSTS
RewriteRule ^posts/$ index.php?do=posts [QSA,L]
RewriteRule ^posts/pagina([0-9]+)$ index.php?do=posts&page=$1 [QSA,L]
RewriteRule ^posts/([A-Za-z0-9_-]+)/$ index.php?do=posts&cat=$1 [QSA,L]
RewriteRule ^posts/([A-Za-z0-9_-]+)/pagina([0-9]+)$ index.php?do=posts&cat=$1&page=$2 [QSA,L]
RewriteRule ^posts/([A-Za-z0-9_-]+)/([0-9]+)/(.*)\.html$ index.php?do=posts&cat=$1&post_id=$2&title=$3 [QSA,L]
RewriteRule ^posts/editar/([0-9]+)$ App/Controller/agregar.php?action=editar&pid=$1 [QSA,L]
# POSTS SHORTEN
RewriteRule ^p/([0-9]+)$ index.php?do=posts&p=$1 [QSA,L]
# RECUPERAR PASS Y VALIDAR CUENTA
RewriteRule ^password/(.+)/([0-9]+)/(.+)/?$ App/Controller/password.php?hash=$1&type=$2&email=$3
RewriteRule ^validar/(.+)$ App/Controller/validar.php?encode=$1 [QSA,L]
# FOTOS
RewriteRule ^fotos/([A-Za-z0-9_-]+).php$ App/Controller/fotos.php?action=$1 [QSA,L]
RewriteRule ^fotos/([A-Za-z0-9_-]+)$ App/Controller/fotos.php?action=album&user=$1 [QSA,L]
RewriteRule ^fotos/([A-Za-z0-9_-]+)/([0-9]+)$ App/Controller/fotos.php?action=album&user=$1&page=$2 [QSA,L]
RewriteRule ^fotos/([A-Za-z0-9_-]+)/([0-9]+)/([A-Za-z0-9_-]+).html$ App/Controller/fotos.php?action=ver&user=$1&fid=$2 [QSA,L]
# MODERACION
RewriteRule ^moderacion/buscador/([0-2]+)/([0-2]+)/(.+)$ App/Controller/moderacion.php?action=buscador&act=search&m=$1&t=$2&texto=$3 [QSA,L]
#HISTORIAL DE MODERACION
RewriteRule ^mod-history/([A-Za-z0-9_-]+)/?$ App/Controller/mod-history.php?ver=$1 [QSA,L]
# SITEMAP & RSS
RewriteRule ^rss/([A-Za-z0-9_-]+)(/([A-Za-z0-9_-]+))?$ App/Controller/rss.php?type=$1&user=$3 [QSA,L]
# COMUNIDADES
RewriteRule ^comunidades(/([A-Za-z0-9_-]+))?(/([0-9]+))?(/([A-Za-z0-9_-]+))?(/([A-Za-z0-9_-]+))?(/([0-9]+))?$ App/Controller/comunidades.php?action=$2&act=$3&bid=$4&page=$5&c_seo=$6&s_seo=$7 [QSA,L]
# LOGIN & REGISTRO
RewriteRule ^(login|registro)/?$ App/Controller/access.php?action=$1 [QSA,L]
# ADMINISTRACION & MODERACION
RewriteRule ^(admin|moderacion)/?$ admin/controller/$1.php?page=$1 [L,QSA]
RewriteRule ^(admin|moderacion)/([A-Za-z0-9_-]+)/?$ admin/controller/$1.php?page=$1&action=$2 [L,QSA]
RewriteRule ^(admin|moderacion)/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/?$ admin/controller/$1.php?page=$1&action=$2&act=$3 [L,QSA]
RewriteRule ^(admin|moderacion)/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/([0-9]+)/?$ admin/controller/$1.php?page=$1&action=$2&act=$3&id=$4 [L,QSA]
# API
RewriteRule ^([A-Za-z0-9_-]+).php$ App/Api/index.php?action=$1 [QSA,L]
# EXTRAS
RewriteRule ^([A-Za-z0-9_-]+)/$ App/Controller/$1.php [QSA,L]
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/$ App/Controller/$1.php?action=$2 [QSA,L]
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/([0-9]+)$ App/Controller/$1.php?action=$2&id=$3 [QSA,L]
# NO PERMITIR
<FilesMatch "^\.">
Require all denied
</FilesMatch>
<FilesMatch "\.(ini|log|cfg|tpl|version|md|cache)$">
Order Allow,Deny
Deny from all
</FilesMatch>
<FilesMatch "(composer|package|yarn)\.(json|lock)$">
Require all denied
</FilesMatch>
<FilesMatch "(\.env|\.gitignore|\.htaccess|\.htpasswd)$">
Require all denied
</FilesMatch>
# Seguridad contra patrones de consulta maliciosos
RewriteCond %{QUERY_STRING} PHP[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} [NC]
RewriteRule .* - [F]
# Control de cach? para archivos estaticos
<FilesMatch "\.(jpg|jpeg|png|gif|webp|svg|js|css|pdf)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
# Compresi?n
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
Header append Vary User-Agent
</IfModule>
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
Header always append X-Frame-Options SAMEORIGIN
Header set X-XSS-Protection "1; mode=block"
Header set X-Content-Type-Options nosniff