请教301重定向
按军哥教程修改301重定向,2个网站,一个成功,一个不成功测试了几次,修改几次还是不成功,只好发帖求助了
log_formatwww.xxx.com'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
server
{
listen 80;
server_name www.xxx.com xxx.com;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/www.xxx.com;
include none.conf;
location ~(plus|member|special|include|data|a|images|templets|uploads|dede)/(.*)\.(pl|php|cgi|asp|aspx|py|tpl|jsp) {return 400;}
location ~ .*\.(php|php5)?$
{
try_files $uri =404;
fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log/home/wwwlogs/www.xxx.com.logwww.xxx.com;
}
server {
server_name xxx.com;
return 301 $scheme://www.xxx.com$request_uri;
} # /etc/init.d/nginx restart
Restarting nginx daemon: nginxnginx: conflicting server name "xxx.com" on 0.0.0.0:80, ignored
nginx: conflicting server name "aaa.com" on 0.0.0.0:80, ignored 你把
if ($host != 'www.xxx.com' ) {
rewrite ^/(.*)$ http://www.xxx.com/$1 permanent;
}
放在
server
{
listen 80;
server_name www.xxx.com xxx.com
这段下面重启NGINX就生效了 上面本身有server {
server_name xxx.com;
你下面在写一段根本没什么意义 域名重复要想xxx.com跳到www.xxx.com,把第一个server_name里的xxx.com删掉,重启 试了楼上回贴的也可以,但好像是不好
用了军哥的方法OK
:victory: :victory:
页:
[1]