IndexIgnore .* *.php *.zip css js fonts img
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/myFolder/(css|js|fonts|img)/(.*)$ [NC]
RewriteRule ^ /myFolder/.%1/%2 [QSA,L]
RewriteRule ^([0-9]+)_(.*)/$ list.php?cat=$1 RewriteRule ^([0-9]+)_(.*)/([0-9]+)/$ list.php?cat=$1&page=$3
(.*)
означает любое количество любых символов.^([0-9]+)_(.*)/$
совпадает с 123_text/
и 123_text/345/
. RewriteRule ^([0-9]+)_(.*)/([0-9]+)/$ list.php?cat=$1&page=$3
RewriteRule ^([0-9]+)_(.*)/$ list.php?cat=$1
1. Редирект на https;
2. Редирект на без www + без повторяющихся слешей;
RewriteCond %{THE_REQUEST} // [OR]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]
RewriteCond %{THE_REQUEST} // [OR]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.|)(.+) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
[OR]
RewriteCond %{HTTPS};%{HTTP_HOST};%{THE_REQUEST} !^on;(?!www\.)[^;]+;(?!.*//) [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.|)(.+) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTP_HOST};%{HTTPS};%{THE_REQUEST} ^(?=(?:www\.|)([^;]+))(?!(?!www\.)[^;]+;on;(?!.*//)) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
server {
listen 123.123.123.123:80 default_server;
server_name 123.com www.123.com;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
charset off;
index index.php index.html;
set $root_path /var/www/www-root/data/www/123.com/public;
root $root_path;
disable_symlinks if_not_owner from=$root_path;
access_log /var/www/httpd-logs/123.com.access.log;
error_log /var/www/httpd-logs/123.com.error.log notice;
error_page 404 /index.php;
location / {
return 301 https://$host$request_uri;
}
location ~ ^/(bouns)?$ {
fastcgi_param SCRIPT_FILENAME $root_path/index.php;
fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
include fastcgi_params;
}
}
Первому RewriteRule передается путь от того места, где находится .htaccess, до запрошенного файла.
^test/(first|second|third)$
должно быть ^(first|second|third)$
<VirtualHost>
, а в .htaccess запрос будет проходить через все RewriteRule снова и снова, до тех пор, пока он не перестанет меняться.RewriteEngine On
RewriteRule ^(first|second|third)$ index.html [END]
RewriteRule ^(.+)$ 404.html [END]
RewriteCond %{HTTP_HOST} ^(www\.)?italy\.domainname\.com$ [NC]
RewriteRule ^contacts$ http://www.domainname.com/contacts?country=Italy [R=301,L]
RewriteCond %{HTTP_HOST} ^(?:www\.)?+(.+)\.(domainname\.com)$ [NC]
RewriteRule ^(contacts)$ http://www.%2/$1?country=%1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^(?:www\.)?+(.+)\.(domainname\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%2/$1?country=%1 [R=301,L]
RewriteCond %{HTTP_COOKIE} (?:^|;\s*)city=([^;]+)
RewriteCond "%1 moskva=url1 omsk=url2 orsk=url3" "^(\S+) .*?\1=(\S+)"
RewriteRule ^ /%2 [R=301,L]
/^(?=.*[а-яё])(?=.*\d)[а-яё\d]+$/ui
/^(?:[а-яё]()|\d())++\1\2$/ui
location / {
resolver 8.8.8.8;
proxy_pass http://$arg_url;
add_header Access-Control-Allow-Origin *;
}
function transform(addr) {
const regEx = /((д(ом)?|стр(оение)?|\/|-)\.?\s*|)\d+((,?\s*(к(ор(п(ус)?)?)?\.?)\s*\d+)|(\s*[а-я])|(\s*\/\s*\d+))?\s*$/;
let result = addr.replace(regEx, function(m0, m1) {
if (m1) {
return m0;
} else {
return 'д. ' + m0;
}
});
return result;
}
console.log(transform('Татарстан, г. Казань, ул. Баумана, 36'));