Nginx 301 redirect

If none of the more specific forums is the right place to ask

Nginx 301 redirect

Postby udo » 2017-05-16 11:42

Hello, I have a problem with 301 redirect.

These my ngninx conf:

server
{
listen 80;

root /var/www/html/realcreditbank;
index index.php index.html index.htm;
charset utf-8;
client_max_body_size 100M;
client_header_buffer_size 16k;
large_client_header_buffers 16 32k;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

proxy_cache_valid 200 301 302 304 5m;
proxy_cache_key "$request_method|$http_if_modified_since|$http_if_none_match|$host|$request_uri";
proxy_hide_header "Set-Cookie";
proxy_ignore_headers "Cache-Control" "Expires";
proxy_cache_use_stale error timeout invalid_header http_500 http_502 http_503 http_504;

server_name realcreditbank.com;
rewrite ^/(.*)$ http://www.realcreditbank.com/$1 permanent;

location ~* ^.+\.(js|css|3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|ttf|woff|doc|docx|xls|xlsx|pdf|iso)$ {
expires 1w;
}

location / {
try_files $uri $uri/ /index.php?$args;
}

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;

location = /50x.html
{
root /var/www/html/;
}

# pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
location ~ \.php$
{
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

location ~* \.(htaccess|htpasswd|svn|git) {
deny all;
}

location ~* ^/admin {
# alias /var/www/html/realcreditbank/admin;
try_files $uri /admin/index.php$is_args$args;
}

location ~* ^/admin/(.+\.php)$ {
try_files $uri /admin/$1?$args;
}
}

I have read this article https://www.digitalocean.com/community/ ... with-nginx.
Redirect doesn't work. Work domain http://www.realcreditbank.com, but http://realcreditbank.com doesn't work.
What is problem? Can you help me?
udo
 
Posts: 1
Joined: 2017-05-16 11:32

Re: Nginx 301 redirect

Postby debiman » 2017-05-17 06:03

please edit your first post to use Code tags around the code.

what are you trying to achieve? provide some context please, and highlight the relevant parts in your nginx config.

how EXACTLY does the redirect "not work"? please show us in FULL DETAIL.
User avatar
debiman
 
Posts: 974
Joined: 2013-03-12 07:18


Return to General Questions

Who is online

Users browsing this forum: No registered users and 7 guests

fashionable