我刚刚在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/
。
我们在HTTPS
页面的大约10,000个帖子中有很多链接,因此对于我们而言,不是在我们的帖子中更改所有这些链接,最简单的方法就是重定向{{1}页面到新的https://store....
页面。
我有一个完整的列表,列出了我们要重定向的旧http
页面。我们仍然在新网站上加载了许多产品(那里有大约100个),仍然需要加载另外900个左右。因此,我们将对某些URL(已加载的产品)使用301重定向,并将302重定向到顶级类别页面,以用于仍需要加载的其余产品。加载这些新产品后,我们会将顶层类别页面中的302重定向更改为301重定向到永久主页。
我只在Nginx中设置HTTPS
服务器,所以这是我的问题:
HTTP
Nginx配置,并在HTTP
Nginx配置下面。******* HTTP NGINX CONFIG *******
HTTPS
******* HTTPS NGINX CONFIG *******
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/; }
}
感谢您的投入!
答案 0 :(得分:0)
您可以考虑创建一个新配置来侦听旧网站网址并创建重写规则以重定向到新网站。
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html
更新1:
server {
listen 443;
server_name store.website.com;
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;
# To rewrite URLs like https://store.website.com/category/this-product.html
rewrite ^/category/(.*).html$ http://www.website.com/store/category/$1 permanent;
# To rewrite URLs like https://store.website.com/that-product.html
rewrite ^/(.*).html$ http://www.website.com/store/category/$1 permanent;
# To rewrite URLs like https://store.website.com/abcasc/q343f/3f3/f3
rewrite ^(.*) http://www.website.com$1 permanent;
}
未经测试。但随意尝试。