server { server_name www.example.com; listen *:80; listen [::]:80 ipv6only=on; if ($uri !~* ^/downloads/(.+)$) { return 301 https://example.com/downloads/$1; } }
if
лучше использовать location.server {
server_name example.com www.example.com;
listen *:80;
listen [::]:80 ipv6only=on;
location / {
return 301 https://example.com$request_uri;
}
location /downloads/ {
root /var/www/html;
}
}
RewriteEngine On
RewriteCond %{HTTP_COOKIE} !REG=
RewriteRule ^ http://example.com/reg [R=302,L]
RedirectMatch 301 ^/link /page
RewriteEngine On
RewriteRule ^link /page [R=301,L]
<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]
Invalid command 'AddHandler\xe2\x80\x8b'
в $header если сделать вардамп выводится следующееstring(324) "HTTP/1.1 200 OK Date: Tue, 11 Dec 2018 10:27:40 GMT Server: Apache X-Powered-By: PHP/5.6.28-pl0-gentoo Content-Length: 51408 Cache-Control: public Content-Transfer-Encoding: Binary Content-Disposition: attachment; filename=2018.12.07_[14:28:30]_+74562697525_103.mp3 Accept-Ranges: bytes Content-Type: audio/mpeg "
echo "<pre>", $header, "</pre>";
HTTP/1.1 200 OK
Date: Tue, 11 Dec 2018 10:27:40 GMT
Server: Apache
X-Powered-By: PHP/5.6.28-pl0-gentoo
Content-Length: 51408
Cache-Control: public
Content-Transfer-Encoding: Binary
Content-Disposition: attachment; filename=2018.12.07_[14:28:30]_+74562697525_103.mp3
Accept-Ranges: bytes
Content-Type: audio/mpeg
$header1=preg_replace('~^.+Content-Disposition: attachment; filename=(.+)Accept-Ranges.+$~is','$1',$header);