我正在配置一个在 apache 下运行的 wordpress 网站,我已将其移至 nginx。该网站是公司活动的一个独立部分,即“交易”。母公司是 KJT Investments Ltd,交易角色是 KJT Aviation。
该网站是KJT航空母公司的 DNS 指向为 kjtaviation.com 提供服务的服务器的 IP 地址。两个网站都由同一个服务器和 IP 地址提供服务。
在 apache 下,重定向位于 .htaccess 中
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
我为 kjtaviation.com 创建了如下服务器文件
server {
listen 95.154.237.186:80;
root /var/www/kjtaviation;
index index.php ;
# Make site accessible from http://kjtaviation.com/
server_name www.kjtaviation.com kjtaviation.com;
access_log /var/log/nginx/kjtaviation.com-access.log;
error_log /var/log/nginx/kjtaviation.com-error.log;
location / {
#try_files $uri $uri/ =404;
# PWI 20151112 from here...
# https://wordpress.org/support/topic/permalinks-nginx-not-working-help-required
try_files $uri $uri/ /index.php?$args;
}
error_page 404 /404.html;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#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;
}
location ~ /\.ht {
deny all;
}
}
我已经为重定向创建了另一个服务器文件......
server {
listen 80;
#implemented by default, change if you need different ip or port
server_name www.kjtinvestments.co.uk kjtinvestments.co.uk ;
access_log /var/log/nginx/kjtinvestments.co.uk.access.log;
error_log /var/log/nginx/kjtinvestments.co.uk.error.log;
rewrite_log on;
return 301 $scheme://www.kjtaviation.com$request_uri;
}
root@srv:/var/www/kjtaviation#
这些文件从 sites-available 链接到 sites-enabled。
到目前为止一切顺利 - kjtaviation 网站正常运行,并且 CURL 报告称 kjtinvestments.co.uk 的重定向正常运行......
srv# curl -I http://www.kjtinvestments.co.uk/
HTTP/1.1 301 Moved Permanently
Server: nginx/1.2.1
Date: Fri, 13 Nov 2015 14:27:35 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.4.45-0+deb7u2
X-Pingback: http://www.kjtaviation.com/xmlrpc.php
Set-Cookie: PHPSESSID=4dvkba202vic8ajv6l0hdntjd5; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: http://www.kjtaviation.com/
问题是,如果你去http://www.kjtinvestments.co.uk我不明白为什么。
如果有人能指出我的错误/遗漏或愚蠢之处,我将不胜感激;-)。