【发布时间】:2014-09-18 13:05:43
【问题描述】:
我刚刚在 Nginx 上重新启动了一个 Wordpress 站点,通过 HTTP 提供内容。目前我们不打算将整个网站迁移到HTTPS,但是旧版网站的页面位于https://store.website.com。
现在这些旧页面的新版本(例如,https://store.website.com/category/this-product.html 或 https://store.website.com/that-product.html)位于 http://www.website.com/store/category/this-product/。
我们在大约 10,000 个帖子中有很多指向 HTTPS 页面的链接,因此对于我们来说,与其更改帖子中的所有这些链接,不如简单地将这些 https://store.... 页面重定向到新的http 页面。
我有我们想要重定向的旧 HTTPS 页面的完整 URL 列表。我们仍在将一些产品加载到新网站(那里大约有 100 个),还需要再加载 900 个左右。因此,我们将对某些 URL(已加载的产品)使用 301 重定向,而对于仍需要加载的其余产品,我们将使用 302 重定向到顶级类别页面。加载这些新产品后,我们会将顶级类别页面的 302 重定向更改为指向永久主页的 301 重定向。
我只在 Nginx 中设置过 HTTP 服务器,所以这是我的问题:
- 我不确定创建 HTTPS 服务器是否会通过两种协议使内容可用,从而为每个帖子创建重复的内容
- 我与下面的配置有多接近来完成我所描述的?注意:下面是我的
HTTPNginx 配置,下面是HTTPSNginx 配置。
*********HTTP NGINX 配置*********
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&$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&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/; }
}
********HTTPS NGINX 配置********
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;
}
}
感谢您的意见!
【问题讨论】:
标签: wordpress http redirect nginx https