<?php
if ($_SERVER['SERVER_PORT'] != '443') {
header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], true, 301);
exit;
}
?>
<html>
<head><title>401 Unauthorized</title></head>
<body><h1>Unauthorized</h1></body>
</html>
ErrorDocument 401 /401.php
RewriteCond %{CF-Connecting-IP} ^XXX.YY.* RewriteCond %{X-Real-IP} ^XXX.YY.*
RewriteCond %{HTTP:CF-Connecting-IP} !^XXX\.YY\.
RewriteCond %{HTTP:X-Real-IP} !^XXX\.YY\.
RewriteEngine On
RewriteCond %{HTTP:X-Real-IP} !^XXX\.YY\.
RewriteRule (.*) - [F]
<VirtualHost 127.0.0.1:8080>
ServerName www.site.ru
Redirect / http://site.ru/
</VirtualHost>
<VirtualHost 127.0.0.1:8080>
ServerName site.ru
DocumentRoot /SOME_PATH/site/site.ru/www
...
</VirtualHost>
<VirtualHost 127.0.0.1:8080>
ServerName site.ru
ServerAlias *.site.ru
VirtualDocumentRoot /SOME_PATH/site/site.ru/%1
...
ProxyPass /phpmyadmin !
ProxyPass / http://site.ru:3000/
<Directory>
можно использовать только в контексте server config, virtual host.AllowOverride None
и Apache не читает .htaccess, либо картинки раздаются вовсе без его участия, например Nginx. RewriteEngine On
RewriteCond %{THE_REQUEST} " /(pages/|[^?]*\.php)" [OR]
RewriteCond %{SERVER_PORT} !443 [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(pages/|)(.*?)(\.php|$) https://site.ru/$2 [R=301,L]
RewriteCond %{DOCUMENT_ROOT}/pages/$1.php -f
RewriteRule ^(.*)$ pages/$1.php [L,QSA]
<Files "protected_file.php">
AuthName "Member Only"
AuthType Basic
AuthUserFile /etc/apache2/.htpasswd
require user Vasily
Satisfy All
</Files>
Satisfy Any
AuthName "Member Only"
AuthType Basic
AuthUserFile /etc/apache2/.htpasswd
require valid-user
Satisfy All
Header set Content-Disposition attachment "expr=%{QUERY_STRING} == 'download=1'"
Header set Content-Disposition attachment env=attach
RewriteCond %{QUERY_STRING} =download=1
RewriteRule ^ - [E=attach:1]
ServerName domain.ru
ServerAlias *.domain.ru
ServerSignature Off
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.ru [NC]
RewriteRule ^/(.*) http://www.domain.ru/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?+.+\.domain\.ru$ [NC]
RewriteRule ^/(.*)\.html$ /index.php?page=$1 [L]
RewriteRule ^/
/
In VirtualHost context, The Pattern will initially be matched against the part of the URL after the hostname and port, and before the query string (e.g. "/app1/index.html"). This is the (%-decoded) URL-path.
In per-directory context (Directory and .htaccess), the Pattern is matched against only a partial path, for example a request of "/app1/index.html" may result in comparison against "app1/index.html" or "index.html" depending on where the RewriteRule is defined.
/
RewriteEngine on
RewriteBase /
Options All -Indexes
RewriteRule ^dist/(.*)$ site/src/dist/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ site/src/index.html [L]
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 expr "! (%{QUERY_STRING} =~ /(?:^|&)key=([^&]+)/ && md5(%{REQUEST_URI}) == $1)"
RewriteRule ^orders/1\. - [F]
/orders/1.jpg
хеш MD5 58fa4178ea5e540a0e02f726a807dc8f
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