location = /api/servertime {
access_log off;
rewrite ^ /index.php break;
include fastcgi.conf;
fastcgi_pass php;
}
location ~ \.php$
location ~ \.php$ {
if ($request_uri ~ "^/api/servertime") {
access_log off;
}
include fastcgi.conf;
fastcgi_pass php;
}
access_log путь [формат [if=условие]];
map $request_uri $loggable {
default 1;
~^/api/servertime 0;
}
server {
# ...
root /var/www/lumen/public;
try_files $uri $uri/ /index.php$is_args$args;
# ...
location ~ \.php$ {
access_log /var/log/nginx/access.log combined if=$loggable;
include fastcgi.conf;
fastcgi_pass php;
}
}
<VirtualHost *:80>
DBDriver mysql
DBDParams "dbname=test user=root pass=xxxxxx"
RewriteMap user2id "dbd:select id from users where name = %s "
RewriteEngine On
RewriteRule ^/user2id/([^/]+) http://domain.com/id/${user2id:$1} [R,L]
php_admin_value open_basedir /home/admin/web/cloud.site.com/public_html:/home/admin/tmp
php_admin_value open_basedir /home/admin/web/cloud.site.com/public_html:/home/admin/tmp:/home/admin/web/cloud.site.com/public_shtml
RewriteRule ^([^/]+/results,[^/]+)$ /component/virtuemart/search/$1 [R=301,L]
'#^([a-z]+\s[a-z]+|[а-яё]+\s[а-яё]+)$#ui'
'#^[a-z]+\s[a-z]+$|^[а-яё]+\s[а-яё]+$#ui'
'#^([a-z]+)\s(?1)$|^([а-яё]+)\s(?2)$#ui'
RewriteCond %{THE_REQUEST} /subdomains/[^/] RewriteRule ^subdomains/[^/]+/(.*) /$1 [R=permanent,L] RewriteCond %{HTTP_HOST} ^(.+)\.site\.ru$ [NC] RewriteCond %{HTTP_HOST} !^www\.site\.ru$ [NC] RewriteCond %{REQUEST_URI} !^/subdomains RewriteRule ^(.*) %{HTTP_HOST}$1 RewriteRule ^(www\.)?(.+)\.site\.ru(.*) /subdomains/$2%{REQUEST_URI} [L]
RewriteCond %{THE_REQUEST} /subdomains/
RewriteRule ^subdomains/([^/]+)/(.*) http://$1.site.ru/$2 [R=301,L]
RewriteCond %{HTTP_HOST} ^(?>www\.|)(.+)\.site\.ru$ [NC]
RewriteRule !^subdomains /subdomains/%1%{REQUEST_URI} [L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.|)site\.ru$ [NC]
RewriteCond %{REQUEST_URI} ^/([^/]+)
RewriteRule ^(.*)$ http://%1.stie.ru/$1 [R=301,L]
location ~ ^/c/(?!index\.php|d\.php|t\.js|app/project/_resource/s/|app/project/[^/]+/js/c\.min\.js) {
return 403;
}
location ^~ /c/ {
return 403;
location ~ ^/c/(index|d)\.php {
fastcgi_pass ...;
include fastcgi_params;
}
location = /c/t.js { }
location /c/app/project/_resource/s/ { }
location ~ ^/c/app/project/[^/]+/js/c\.min\.js { }
}
^
означает начало строки.^recommend$
не может совпасть с чем-то вроде bla/bla/recommend
RewriteCond %{QUERY_STRING} (^|&)tmpl\=component($|&)
RewriteRule /recommend$ /? [L,R=301]
Redirect 301 /https://old.com/noob /https://new.com/good
Redirect 301 /noob https://new.com/good
RedirectMatch 301 ^/noob$ https://new.com/good
RewriteCond %{HTTP_HOST} ^old\.com$
RewriteRule ^noob$ https://new.com/good [R=301,L]
<base href="http://site.ru/">
htmlbook.ru/html/baseDirectorySlash Off
в htaccess. REQUEST_FILENAME
The full local filesystem path to the file or script matching the request, if this has already been determined by the server at the time REQUEST_FILENAME is referenced. Otherwise, such as when used in virtual host context, the same value as REQUEST_URI. Depending on the value of AcceptPathInfo, the server may have only used some leading components of the REQUEST_URI to map the request to a file.
REQUEST_URI
The path component of the requested URI, such as "/index.html". This notably excludes the query string which is available as its own variable named QUERY_STRING.
%{REQUEST_FILENAME} -> /var/www/news/list
%{REQUEST_URI} -> /news/list
RewriteEngine On
RewriteRule ^page/(?!index\.php)(.+) /page/index.php?$1 [L]
server {
...
root /home/site/public_html;
rewrite ^/(ru|en)?/?(faq|news|page|catalogue|basket|photos|search|users)(.*)$ /index.php?lang=$1&module=$2&mod_rewrite=$3;
rewrite ^/$ /index.php;
location / { }
location ~ \.php$ {
fastcgi_pass unix:/tmp/php-fpm7.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|woff|ogg|mpe?g|avi|zip|gz|rar)$ {
add_header Pragma public;
add_header Cache-Control "public";
access_log /home/site/cache.log;
expires 1d;
}
}