title: Nginx HTTP & HTTPS Configs: Redirect SOME URLs
body: <p>I have just relaunched a Wordpress site on Nginx, serving content over <code>HTTP</code>. At present we are not looking to migrate the entire site to <code>HTTPS</code>, however the old version of the site had pages at <code>https://store.website.com</code>.</p>
  
  <p>Now the new versions of those old pages (for instance, <code>https://store.website.com/category/this-product.html</code>, or, <code>https://store.website.com/that-product.html</code>) live at <code>http://www.website.com/store/category/this-product/</code>.</p>
  
  <p>We have lots of links in about 10,000 posts to the <code>HTTPS</code> pages, so for us right now instead of changing all of those links in our posts, it makes the most sense to simply redirect those <code>https://store....</code> pages to the new <code>http</code> page.</p>
  
  <p>I have a full list of the URLs of the old <code>HTTPS</code> pages that we want to redirect. We are still loading a number of products in to the new website (there are about 100 there), and still need to load in another 900 or so. Therefore, we will be using 301 redirects for some URLs (the products already loaded), and 302 redirects to the top level category page for the remainder of the products that still need to be loaded. Once those new products are loaded, we will change the 302 redirect from the top-level category page, to be a 301 redirect to the permanent home.</p>
  
  <p>I have only ever setup <code>HTTP</code> servers in Nginx, so here are my questions:</p>
  
  <ol>
  <li>I am not sure if creating an HTTPS server will create a duplicate content for each post or not, by making the content available via two protocols</li>
  <li>How close am I with the config below to accomplishing what I have described? Note: below you will first find my <code>HTTP</code> Nginx config, and below the <code>HTTPS</code> Nginx config.</li>
  </ol>
  
  <p><strong>*******HTTP NGINX CONFIG*******</strong></p>
  
  <pre><code>    server {
              listen   80;
  
              access_log   /var/log/nginx/access.log;
              error_log    /var/log/nginx/error.log crit;
  
              root /var/www;
              index index.php;
  
              server_name website.com www.website.com;
  
              client_max_body_size 100M;
  
              location / {
                      try_files $uri $uri/ /index.php?q=$uri&amp;$args;
                      #auth_basic "Admin Login";
                      #auth_basic_user_file /etc/nginx/pma_pass;
              }
  
              error_page 404 /404.html;
  
              # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
              location ~ \.php$ {
                      try_files $uri =404;
                      fastcgi_pass 127.0.0.1:9000;
                      # With php5-fpm:
                      #fastcgi_pass unix:/var/run/php5-fpm.sock;
                      fastcgi_index index.php;
                      include fastcgi_params;
                      fastcgi_read_timeout 60;
              }
              # BEGIN W3TC CDN
              location ~ \.(ttf|ttc|otf|eot|woff|font.css)$ {
                 add_header Access-Control-Allow-Origin "*";
              }
              # END W3TC CDN
              #Yoast sitemap
              location ~ ([^/]*)sitemap(.*)\.x(m|s)l$ {
                      rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent;
                      rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last;
                      rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
                      rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&amp;sitemap_n=$2 last;
                      access_log off;
              }
              # Example of the style of single-page redirects we are currently using
              location = /this-page/ { return 301 /store/category/that-page/; }
      }
  </code></pre>
  
  <p><strong>*******HTTPS NGINX CONFIG*******</strong></p>
  
  <pre><code>    server {
             listen 443;
             server_name store.website.com;
  
             root /var/www;
             index index.php;
  
             ssl on;
             ssl_certificate /etc/nginx/ssl/server.crt;
             ssl_certificate_key /etc/nginx/ssl/server.key;
  
             ssl_session_timeout 10m;
  
             ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
             ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
             ssl_prefer_server_ciphers on;
  
             location / {
                     try_files $uri $uri/ =404;
             }
      }
  </code></pre>
  
  <p>Thanks for your input!</p>