I want that redirect every request ( like "google.com" , "yahoo.com" ) to mydomain.com
**I setup dns for my user's and force them to send their http request to mydomain.com like every user is expire and want to see internet should redirect to mydomain.com
or if some body enter an ip address like : 172.16.16.16 its request should redirect to mydomain.com
I found this :
rewrite ^ $scheme://www.mydomain.com$request_uri permanent;
but it has error on browser :
Error code: ERR_TOO_MANY_REDIRECTS
How should i write this redirect rule?
Here is my site configure in /etc/nginx/site-available/mydomain.com :
server {
listen 80;
listen 443 ssl;
server_name 100;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
access_log /var/log/nginx/expire.access.log;
location / {
root /var/www;
index index.html index.htm;
}
pagespeed on;
pagespeed FileCachePath /var/ngx_pagespeed_cache;
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
}
}
server {
listen 80;
server_name 100.mydomain.com;
#rewrite ^ $scheme://100.mydomain.com$request_uri permanent;
rewrite ^ $scheme://100.mydomain.com$request_uri redirect;
}
server {
listen 80;
server_name 200.mydomain.com;
return 301 $scheme//100.mydomain.com$request_uri;
}
server {
listen 80;
server_name 300.mydomain.com;
access_log /var/log/nginx/300/access.log;
location / {
root /usr/share/nginx/adpic;
index index.php index.html index.htm;
autoindex on;
}
}