nginx configuration to prevent multiple domain blind jump when there is no www

2010-11-03  来源:本站原创  分类:OS  人气:123 

nginx installed, the default nginx.conf only one server configuration.

Generally like Jiangzi of:

server
 {
  listen       80;
  server_name www.91loli.com;
  index index.html index.htm index.php;
  root  /home/www;
  location ~ .*\.(php|php5)?$
   {
    fastcgi_pass  unix:/tmp/php-cgi.sock;
    fastcgi_index index.php;
    include fcgi.conf;
   }
  location /status {
   stub_status on;
   access_log   off;
  }
  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
   {
    expires      30d;
   }
  location ~ .*\.(js|css)?$
   {
    expires      12h;
   }
  log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
  access_log  /home/logs/access.log  access;
 }

Of course the N virtual hosts into nginx.conf inside, but this inconvenience to management.

So gorgeous insert the following configuration files:

include /usr/local/nginx/vhost/*.conf;

This can include N-configured virtual hosts.

Virtual host configuration not write, you can copy the above are readily available.

Here is address multiple domain name (multiple virtual hosts), the access to the domain name without www will jump to the default domain name issues.

For example, my ~ visit yjkong.com , will jump to www.91loli.com . The key is the search engine will be included into the silly.

Ado, just need to write a server_name:

server_name www.yjkong.com;
server_name yjkong.com;

I drop site: Royal Sister control will LORI

相关文章
  • nginx configuration to prevent multiple domain blind jump when there is no www 2010-11-03

    nginx installed, the default nginx.conf only one server configuration. Generally like Jiangzi of: server { listen 80; server_name www.91loli.com; index index.html index.htm index.php; root /home/www; location ~ .*\.(php|php5)?$ { fastcgi_pass unix:/t

  • multi domain nginx configuration to prevent the blind do not jump at www 2010-11-03

    nginx installed, the default nginx.conf only one server configuration. Jiangzi generally like this: server { listen 80; server_name www.91loli.com; index index.html index.htm index.php; root /home/www; location ~ .*\.(php|php5)?$ { fastcgi_pass unix:

  • Explain the use of squid + nginx load balancing run multiple stand-alone configuration of squid 2011-05-16

    squid + nginx load balancing to run multiple stand-alone squid. Now, in a large traffic website, squid reverse proxy caching has become a commonly used technology. However, we all know, squid itself does not support SMP, so the original does not supp

  • Nginx reverse proxy multiple domain names 2011-04-12

    Nginx reverse proxy multiple domain names, domain names need to bring proxy access, then just add in the location proxy_set_header Host $host; Can.

  • Apache configuration http.conf bound by multiple domain names and two Domain Names 2011-07-29

    Apache configuration http.conf bound by multiple domain names and two Domain Names By Minidxer | April 12, 2008 Apache is the most popular HTTP server software, one of its to fast, reliable (stable) is known, and can be extended through simple API, P

  • Nginx configuration using multiple php fastcgi load balancing 2010-06-08

    Configuration is very simple, fully embodies the nginx configuration powerful and simple ^ ^ The following is a rough diagram server: Most front-end application is a nginx server, all the static content by nginx to handle, and all php requests are sp

  • nginx pseudo-static redirection, including the domain name. directory. files and other methods 2011-05-20

    Web site construction needs in many cases of redirection: structural changes, such as web directory, web page rename, change the extension page, and changes in this domain. If you do not do redirection, user favorites and search engine database in th

  • nginx configuration file have more effect on the optimization of the following: 2011-07-13

    nginx configuration file have more effect on the optimization of the following: 1 worker_processes 8; nginx processes, it is recommended to specify the number of cpu, usually a multiple of it. 1 worker_cpu_affinity 00000001 00000010 00000100 00001000

  • Tomcat5.5 (6.0) configuration - more than a domain name - 2010-05-28

    August 7 Tomcat5.5 (6.0) configuration - and more binding domain and the virtual directories need to modify the configuration file: Tomcat 5.5 (6.0) \ conf \ server.xml server.xml changes as follows: (A) Multi-domain binding 1. If you want to bind th

  • under the nginx configuration windows and the resin 2010-02-14

    windows and the resin under the nginx configuration Russian Chupin endorsement to nginx reverse proxy server is a substitute for one of the apache. This article focuses on the configuration of nginx and resin

  • Tomcat multiple domain names and secondary binding domain 2010-06-01

    Tomcat bound to achieve multiple domain names, domain name or more two ways: First of all, your domain name to resolve to the tomcat server where the server, such as your IP is 102.11.28.16; Intend to deploy the machine three applications, correspond

  • In the non-stop service where Nginx Nginx configuration smooth change 2010-06-02

    6, the service does not stop Nginx Nginx configuration under a smooth change, modify / usr / local / webserver / nginx / conf / nginx.conf configuration file, run the following command to check the configuration file is correct: / Usr / local / webse

  • Smooth change Nginx Configuration 2010-06-27

    Modify the nginx configuration each time, all need to stop the nginx service, and then start the service, so the modified configuration to take effect. It does every time very troublesome. Next, let's see how smooth the change nginx configuration. Mo

  • Lucene Study Notes 3 - create multiple domain check 2010-07-19

    / * Create a search, search the directory just created an index * / IndexSearcher indexSearcher = new IndexSearcher (path); / * Here we need only search a directory * / IndexSearcher indexSearchers [] = (indexSearcher); / * We need to search two fiel

  • Nginx configuration, the details and start running 2010-10-14

    Nginx configuration during our time there will be a lot of places do not understand, in fact, sometimes for as long as you can find a way of thinking more than you want to solve the problem. Here we introduce to you the detailed information about Ngi

  • Nginx configuration file without restarting the dynamic loading 2011-04-18

    Refresh a bit nginx configuration file, such as prohibiting the 403,404 nginx error page displays the version number, but every time to stop and then start Nginx Nginx trouble feeling it. Search data, finally found a very simple command, that is, kil

  • Apache Rewrite to achieve a URL and domain name jump jump 2011-07-28

    Rewirte main function is to realize the URL of the jump, it is based on Perl regular expression language. Can be based on server-level (httpd.conf) and per-directory (. Htaccess) in two ways. If you want to use the rewrite module, you must first inst

  • Nginx configuration instructions 2010-06-19

    user www www; # Run the user worker_processes 8; # Start the process generally open four or eight, and then further on the opening words of optimization is not too large, open lot, would affect the primary process scheduling, occupancy will increase

  • nginx configuration must write resolver 2010-08-18

    Speaking funny ah, but the resolver is too important. Such as in front of nginx, followed by tomcat, tomcat redirect instruction sometimes use to do relative path of the transfer, such as the following code: def logout = ( session.user = null session

  • [Reprinted] nginx configuration file Xiangjie 2010-09-15

    user www www; # Which user to start nginx in front of the user, followed by group worker_processes 4; # nginx number of work processes # [Debug | info | notice | warn | error | crit] error log of the level and location error_log / var / htdocs / logs