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]
location /internal_redirect/ {
proxy_pass http://google.com/;
}
location /internal_redirect/ {
rewrite ^/internal_redirect/(.*) /$1 break;
proxy_pass http://google.com;
}
^(?: (word1) | (word2) | ... )+
(?(id/name)yes-pattern|no-pattern)
https://docs.python.org/3/library/re.html(?>...)
, которая не поддерживается в Python, но её можно имитировать с помощью позитивной опережающей проверки (?=...)
pattern = r"""
(?xm)
^
(?=
(
(?: \b (?P<a> белый | серый | красные ) \b
| \b (?P<b> бегемот[ы]? |гиппопотам[ы]? ) \b
| \b (?P<c> дикий | злой ) \b
| \w+
| [^\w\n]+
)+
)
)
(?(a)|(?!))
(?(b)|(?!))
(?(c)(?!)|)
"""
upstream api {
server 127.0.0.1:7777;
}
server {
listen 80;
listen [::]:80;
server_name example.com;
root /home/iam/project/dist;
location / {
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://api/;
}
location /static/ {
try_files $uri @cdn_uploads;
}
location @cdn_uploads {
root /home/iam/cdn/uploads;
rewrite ^/static(/.*)$ $1 break;
}
}
location /api/ {
proxy_pass http://starter_api/;
}
location = /api {
proxy_pass http://starter_api/;
}
<IfModule mod_rewrite.c>
# Enable rewrite rules
RewriteEngine on
# Base directory
RewriteBase /
# Deny direct access to .txt files
RewriteRule ^content/(.*)\.txt$ - [R=404,L]
RewriteRule ^\d+$ my.php [L]
# All URL process by index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) index.php [PT,L]
</IfModule>
RewriteEngine on
RewriteRule ^chtotam$ /fignya/chtotam [R=301,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]