set $main_host 'example.com';
if ($host != $main_host) {
rewrite ^(.*)$ http://$main_host/?q=example$1 redirect;
break;
}
if ($host = $main_host) {
rewrite http://$main_host http://$main_host/?q=example$1 redirect;
break;
}
rewrite ^ $scheme://example.com\?q=example break;
return 301 $scheme://example.com\?q=example$request_uri;
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)parts\.com [NC]
RewriteRule (.*)$ http://%1part.com [L,R=301]
RewriteCond %{HTTP_HOST} ^(.*)parts\.net [NC]
RewriteRule (.*)$ http://%1part.com [L,R=301]
RewriteCond %{HTTP_HOST} ^(.*)\.net [NC]
RewriteRule (.*)$ http://%1.com [L,R=301]
RewriteCond %{HTTP_HOST} ^(.*)\.COM [NC]
RewriteRule ^$ index.php?q=%1 [NC,QSA]
if ($http_host ~ "^(.*)parts.com"){
set $rule_0 1$rule_0;
set $bref_1 $1;
}
if ($rule_0 = "1"){
rewrite /(.*)$ http://$bref_1part.com permanent;
}
if ($http_host ~ "^(.*)parts.net"){
set $rule_2 1$rule_2;
set $bref_1 $1;
}
if ($rule_2 = "1"){
rewrite /(.*)$ http://$bref_1part.com permanent;
}
if ($http_host ~ "^(.*).net"){
set $rule_3 1$rule_3;
set $bref_1 $1;
}
if ($rule_3 = "1"){
rewrite /(.*)$ http://$bref_1.com permanent;
}
if ($http_host ~* "^(.*).COM"){
set $rule_4 1$rule_4;
set $bref_1 $1;
}
if ($rule_4 = "1"){
rewrite ^/$ /index.php?q=$bref_1;
}
server {
listen 80;
server_name .example.*;
if ($arg !~ q=example) { rewrite ^(.*)$ http://example.com/?q=example$1 redirect; }
}
Firefox определил, что сервер перенаправляет запрос на этот адрес таким образом, что он никогда не завершится.
if ($args !~ q=example){
rewrite ^(.*)$ http://example.com/?q=example$1 redirect;
break;
}
nginx: [emerg] unknown "arg" variable
server {
listen 80;
listen 443;
server_name example.com examples.com example.net examples.net;
root /var/www/html/landingpages/lp;
if ( $host !~ example.com){
rewrite ^(.*)$ https://example.com/? redirect;
break;
}
#===============================SSL
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
#==================================
location ~* \.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|xml|docx|xlsx)$ {
root /var/www/html/landingpages/lp;
index index.html index.php;
access_log off;
expires 30d;
proxy_cache_valid 404 1m;
}
#==============================
location @drupal{
include fastcgi_params;
fastcgi_param QUERY_STRING q=$uri&$args;
fastcgi_param SCRIPT_NAME /index.php;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~* \.(txt|log)$ {
allow 192.168.0.0/16;
deny all;
}
location ~ \..*/.*\.php$ {
return 403;
}
location ~ ^/sites/.*/private/ {
return 403;
}
location ~* ^/.well-known/ {
allow all;
}
location ~ (^|/)\. {
return 403;
}
#=============================
location / {
try_files $uri /index.php?$query_string; # For Drupal >= 7
index index.php index.html index.htm;
}
#=============================
location @rewrite {
# rewrite ^/(.*)$ /index.php?q=$1;
# rewrite ^/(.*)$ /index.php?q=precisiontherapysauna.com;
}
location ~ /vendor/.*\.php$ {
deny all;
return 404;
}
location ~ '\.php$|^/update.php' {
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
include fastcgi_params;
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
try_files $uri @rewrite;
}
location ~ ^(/[a-z\-]+)?/system/files/ { # For Drupal >= 7
try_files $uri /index.php?$query_string;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
rewrite ^(.*)$ http://example.com/?q=example? redirect;
#if ( $arg_q !~ part) { rewrite ^(.*)$ http://example.com/?q=example? redirect;}
#if ( $query_string !~ example ) {rewrite ^(.*)$ http://example.com/?q=example? redirect;}
приводили к вышеописанным проблемам. #if ( $arg_q !~ part) { rewrite ^(.*)$ http://example.com/?q=example? redirect;}
server {
listen 80;
server_name ~^(tst\.)?(?<domain>.+)(\.(ru|com|xn--p1ai))$;
root /var/www/settin.ru/web/;
if ($arg_q != $domain){
rewrite ^(.*)$ http://$host$1?q=$domain redirect;
break;
}
}
#if ( $arg_q !~ example) { rewrite ^(.*)$ http://example.com/?q=example? redirect;}
, разве что проверяется точное соответствие, а не содержание. С break`ом или без, результат был един. Отваливаются cssУ меня то не отваливаются. да и вообще можно прописать чтобы их это правило не касалось.
В случае обычного рерайта без проверки аргумента (какой пользователь будет специально вводить аргумент, чтобы его проверять?) начинает циклить.У меня-то ничего не циклит. ты переходил по моим ссылкам? Всё работает.
Ваше правило по сути повторяется с вышепреведенным мной
set $domain 'example';
if ($arg_q != $domain){
rewrite ^(.*)$ $scheme://$host$1?q=$domain redirect;
break;
}