forked from OkayCMS/Okay_Lite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.htaccess
125 lines (102 loc) · 6.03 KB
/
.htaccess
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
# php_flag display_errors on
# php_flag display_startup_errors on
#php_value session.cookie_httponly true
AddDefaultCharset UTF-8
ErrorDocument 404 /404
RewriteEngine on
#RewriteBase /
# Редирект с повторяющихся слешей
RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
RewriteRule ^(.*)$ %1/%2 [R=301,L]
# Редирект со слеша в конце на без него
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^(.+)/$ %1 [R=301,L]
# Кэширование / поддерживается не на всех хостингах
<ifmodule mod_expires.c>
<filesmatch "\.(jpg|jpeg|png|gif|js|css|swf|ico|woff|mp3)$">
ExpiresActive on
ExpiresDefault "access plus 7 days"
</filesmatch>
</ifmodule>
# Gzip сжатие / поддерживается не на всех хостингах
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/css
<ifmodule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</ifmodule>
</ifmodule>
# Google PageSpeed Insights модуль PageSpeed,есть не на всех хостингах и не везде может работать, нужно уточнять у хостеров
<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedRewriteLevel CoreFilters
ModPagespeedEnableFilters make_google_analytics_async
ModPagespeedEnableFilters prioritize_critical_css
ModPagespeedEnableFilters defer_javascript
ModPagespeedEnableFilters sprite_images
ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp
ModPagespeedEnableFilters collapse_whitespace,remove_comments
</IfModule>
# Редирект с page-1 на основную страницу в ЧПУ
RewriteCond %{REQUEST_URI} ^(.*)/page-1(?![0-9])(.*)$
RewriteRule ^(.*)$ %1%3 [R=301,L]
# Редирект с page=1 на основную страницу без ЧПУ
RewriteCond %{QUERY_STRING} ^(.*)&?page=1(?![0-9])(.*)$
RewriteRule ^(.*)/?$ /$1?%1%3 [R=301,L]
# Админка теперь по адресу /backend
RewriteRule ^admin/?$ backend [L]
# Каталог товаров
RewriteRule ^([a-z]{2}/)?catalog/([^/]+)/?$ index.php?module=ProductsView&category=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?catalog/([^/]+) index.php?module=ProductsView&category=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?products/([^/]+)/?$ index.php?module=ProductView&product_url=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?all-products/?$ index.php?module=ProductsView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?all-products/([^/]+) index.php?module=ProductsView&lang_label=$1&page_url=all-products [L,QSA]
RewriteRule ^([a-z]{2}/)?(discounted|bestsellers)/?$ index.php?module=ProductsView&lang_label=$1&mode=$2 [L,QSA]
RewriteRule ^([a-z]{2}/)?(discounted|bestsellers)/([^/]+) index.php?module=ProductsView&lang_label=$1&page_url=$2&mode=$2 [L,QSA]
RewriteRule ^([a-z]{2}/)?brands/?$ index.php?module=BrandsView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?brands/([^/]+) index.php?module=ProductsView&brand=$2&lang_label=$1 [L,QSA]
# Блог или новости
RewriteRule ^([a-z]{2}/)?(blog|news)/([^/]+)/?$ index.php?module=BlogView&url=$3&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?(blog|news)/?$ index.php?module=BlogView&lang_label=$1 [L,QSA]
# Избранное
#RewriteRule ^([a-z]{2}/)?wishlist/?$ index.php?module=WishlistView&lang_label=$1 [L,QSA]
#RewriteRule ^([a-z]{2}/)?wishlist/([^/]+)/?$ index.php?module=WishlistView&id=$2&lang_label=$1 [L,QSA]
#RewriteRule ^([a-z]{2}/)?wishlist/delete/([^/]+)/?$ index.php?module=WishlistView&id=$2&action=delete&lang_label=$1 [L,QSA]
# Сравнение
#RewriteRule ^([a-z]{2}/)?comparison/?$ index.php?module=ComparisonView&lang_label=$1 [L,QSA]
# Корзина и заказы
RewriteRule ^([a-z]{2}/)?cart/?$ index.php?module=CartView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?cart/([0-9]+)/?$ index.php?module=CartView&variant=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?cart/remove/([^/]+)/?$ index.php?module=CartView&delete_variant=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?order/([^/]+)/?$ index.php?module=OrderView&url=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?order/?$ index.php?module=OrderView&lang_label=$1 [L,QSA]
# Для пользователей
RewriteRule ^([a-z]{2}/)?user/login/?$ index.php?module=LoginView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?user/register/?$ index.php?module=RegisterView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?user/logout/?$ index.php?module=LoginView&action=logout&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?user/password_remind/?$ index.php?module=LoginView&action=password_remind&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?user/password_remind/([0-9a-z]+)/?$ index.php?module=LoginView&action=password_remind&code=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?user/?$ index.php?module=UserView&lang_label=$1 [L,QSA]
# Google sitemap
RewriteRule ^([a-z]{2}/)?sitemap\.(xml|php)$ sitemap.php?lang_label=$1 [L,QSA]
# XML
RewriteCond %{REQUEST_URI} ^(.*)/yandex\.xml$ [NC]
RewriteRule ^(.*)$ %1/feed.xml [R=301,L]
RewriteRule ^feed\.xml?$ feed.php [L,QSA]
# feedback
RewriteRule ^([a-z]{2}/)?contact/?$ index.php?module=FeedbackView&lang_label=$1 [L,QSA]
#downloads
RewriteRule ^([a-z]{2}/)?order/([^/]+)/([^/]+)/?$ index.php?module=OrderView&url=$2&file=$3&lang_label=$1 [L,QSA]
# Ресайз картинок на лету
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^files/(.+)/(.+) resize/resize.php?object=$1&file=$2&token=%{QUERY_STRING} [L,QSA]
# Статические страницы
RewriteRule ^([a-z]{2}/?)?/?$ index.php?module=MainView&page_url=&lang_label=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]{2}/)?(.+)/?$ index.php?lang_label=$1&module=PageView&page_url=$2 [L,QSA]