/
RewriteEngine on
RewriteBase /
Options All -Indexes
RewriteRule ^dist/(.*)$ site/src/dist/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ site/src/index.html [L]
Redirect 301 /oldpage https://site/newpage
RewriteRule ^([^?]*)$ /index.php?path=$1 [NC,L,QSA]
RewriteRule ^oldpage$ https://site/newpage [R=301,L]
DirectoryIndex index.html index.shtml index.pl index.cgi index.php
RewriteEngine On
RewriteBase /
# HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^www.site.ru$ [NC]
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]
RewriteRule ^oldpage$ https://site.ru/newpage [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !/admin/
RewriteRule ^([^?]*)$ /index.php?path=$1 [NC,L,QSA]
<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>
RewriteRule ^pages/articles$ /articles [R=301,L]
RewriteRule ^pages/about$ /about [R=301,L]
RewriteRule ^news\.php$ /news [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?query=$1 [QSA,L]
RewriteCond %{THE_REQUEST} //
RewriteRule ^(.*)$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?route=$1 [B,L,QSA]
server {
listen *:12901;
server_name test.lan;
location / {
proxy_pass http://lan_nodes;
//....
}
location ~ ^/static/.*\.(jpg|jpeg|gif|png|webp|ico|css|bmp|swf|js|html|txt|ejs|json)$ {
root /test/vendor;
expires 10d;
}
location ~ \.(jpg|jpeg|gif|png|webp|ico|css|bmp|swf|js|html|txt|ejs|json)$ {
root /test/app/dist/images;
expires 10d;
}
}
RewriteCond expr "tolower(%{REQUEST_URI}) =~ /(.+)/"
RewriteRule [A-Z] %1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?site1\.ru$
RewriteRule ^$ https://site2.ru/ [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?site1\.ru$
RewriteRule ^catalog/krovlya/(profnastil/)?$ https://site3.ru/$0? [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?site1\.ru$
RewriteRule ^catalog/krovlya/gibkaya_cherepitsa_/$ https://site3.ru/catalog/krovlya/gibkaya-cherepitsa/? [R=301,L]
RewriteCond expr "! (%{QUERY_STRING} =~ /(?:^|&)key=([^&]+)/ && md5(%{REQUEST_URI}) == $1)"
RewriteRule ^orders/1\. - [F]
/orders/1.jpg
хеш MD5 58fa4178ea5e540a0e02f726a807dc8f
rewrite ^/index.video$ /index.html;
location = /index.video {
try_files /index.html =404;
}
Note that when you specify an ErrorDocument that points to a remote URL (ie. anything with a method such as http in front of it), Apache HTTP Server will send a redirect to the client to tell it where to find the document, even if the document ends up being on the same server. This has several implications, the most important being that the client will not receive the original error status code, but instead will receive a redirect status code.
ErrorDocument 404 /404.php
Необходимо иметь в виду, что при использовании индексного файла делается внутреннее перенаправление и запрос может быть обработан уже в другом location’е. Например, в такой конфигурации:location = / { index index.html; } location / { ... }
запрос “/” будет фактически обработан во втором location’е как “/index.html”.
location = /
вместо index нужен try_files.server {
listen 80;
server_name localhost;
index index.html;
root C:/Workspace/landing;
location = / {
try_files /index.html =404;
}
location /images/ { }
location /css/ { }
location /js/ { }
location / {
root C:/Workspace/frontend/dist/app-frontend;
try_files $uri $uri/ /index.html;
}
}
RewriteRule ^(test\.php)$ https://username:password@dev.test.com/$1 [R=302,L,NE]