###前提・実現したいこと
NginxでURIの書き換えをしているのですが、期待通りにURIが書き換えられませんでした。
現在起きている事象は、下記の [No.1] ~ [No.4] の事象です。
[No.1] http://example.com にアクセスした時、https://www.example.com/ にリダイレクトができない 。
[No.2] https://example.com にアクセスした時、https://www.example.com/ にリダイレクトができない 。
[No.3] http://www.example.com/index.php にアクセスした時、https://www.example.com/ にリダイレクトができない 。
[No.4] http://example.com/index.php にアクセスした時、https://www.example.com/ にリダイレクトができない 。
また、定義している設定ファイルは下記の通りです。
ご教授の程、宜しくお願いいたします。
設定ファイル
server {
listen 80;
server_name www.example;
return 301 https://www.example$request_uri;
}
server {
listen 443 ssl;
server_name www.example;
ssl_certificate /usr/local/nginx/ssl/server.crt; ssl_certificate_key /usr/local/nginx/ssl/server.key; # ssl_password_file /etc/nginx/ssl/cert.password; root /var/www/html/example; access_log /var/log/nginx/example_access.log; error_log /var/log/nginx/example_error.log notice; rewrite_log on; location / { index index.html index.php; try_files $uri $uri/ @handler; expires max; } location /. { return 404; } location @handler { rewrite / /index.php; } location = / { set $first_language $http_accept_language; set $language_suffix 'english'; if ($first_language ~* 'ja') { set $language_suffix 'japanese'; } return $scheme://$host/$language_suffix/$1; } location ~ .php/ { rewrite ^(.*.php)/ $1 last; } location ~ .php$ { if (!-e $request_filename) { rewrite / /index.php last; } expires off; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /usr/local/nginx/fastcgi_params; }
}
###補足情報(言語/FW/ツール等のバージョンなど)
Vagrant Installed Version: 1.8.0
PHP 5.5.9-1ubuntu4.14 (cli) (built: Oct 28 2015 01:34:46)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
PHP 5.5.9-1ubuntu4.14 (fpm-fcgi) (built: Oct 28 2015 01:38:24)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
nginx version: nginx/1.9.11
built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.1)
built with OpenSSL 1.0.1f 6 Jan 2014
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/usr/local/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --add-dynamic-module=/usr/build/3party_module/nginx_accept_language_module
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/02/22 00:50