0

この投稿http://www.ewanleith.com/blog/900/10-million-hits-a-day-with-wordpress-using-a-15-serverを見た後、サーバーを apache2 から nginx に変更しました。私はコンピュータ オタクではありません。手順に従いました。その後、このサイトは完璧でしたが、1 つのことを除いては、www 以外から www への変更でした。これを行う方法についてネットで検索しました。彼らが言った modrewrite を試してみましたが、最悪になりました。今のところ、wordpress を使用し、一般設定http://www.pageantly.comに設定しているため、www に向けられています。それでも、私は静的ディレクトリを持っており、それは単純な非www. /etc/nginx/conf.d/ にある私の default.conf と、上記のリンクを含むチュートリアルをご覧ください。

server {
server_name pageantly.com www.pageantly.com;
root /var/www/;
listen 8080;
## This should be in your http block and if it is, it's not needed here.
index index.html index.htm index.php;

include conf.d/drop;

 location / {
            # This is cool because no php is touched for static content
try_files $uri $uri/ /index.php?q=$uri&$args;
    }

        location ~ \.php$ {
        fastcgi_buffers 8 256k;
        fastcgi_buffer_size 128k;
        fastcgi_intercept_errors on;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/dev/shm/php-fpm-www.sock;
    }

# BEGIN W3TC Page Cache cache
location ~ /wp-content/w3tc/pgcache.*html$ {
add_header Vary "Accept-Encoding, Cookie";
   } 
[...]
}
# END W3TC Page Cache core

}

4

2 に答える 2

1

理想的には、各ドメイン (サブドメインを含む) には個別のserverブロックが必要です。それによって、構成は次のようになります。

# Following block redirects all traffic coming to pageantly.com to www.pageantly.com
server {
  server_name pageantly.com;
  listen 8080;

  # Send a 301 permanent redirect to any request which comes on this domain
  return 301 http://www.pageantly.com$request_uri;
}

# Following block handles requests for www.pageantly.com
server {
  server_name www.pageantly.com;
  listen 8080;
  root /var/www;
  [...] # all your default configuration for the website
}

これを達成するためのもう 1 つの不潔で非効率的な方法は、ifドメイン値を読み取り、それに応じてトラフィックをリダイレクトする (pageantly.com の場合) または要求を処理する (www.pageantly.com の場合) フローを分岐するステートメントを導入することです。そのルートを通らないことをお勧めします。

お役に立てれば。

于 2012-12-27T14:06:32.540 に答える
1

AWS で Route 53 を使用している場合。その場合、そのようなことをする必要はありません。Route53 自体でエイリアスを作成し、非 www が www にリダイレクトされるように構成できます。

于 2012-12-28T10:47:27.713 に答える