Redirection 301 create "Redirection loop" while using wordpress site

Dear All,

I am very new to nginx and trying to learn it from very basic. i have a
website and i am willing to remove the “www” before my actual domain
name.
the solution so far i have find out on google is very simple.

so when ever any of the visitor visits my website by using www.xxx.com
he
should be redirected to xxx.com. fortunately everything is working as
expected i can load php files and html file correctly, however when i
try
to load my actual website my browser shows error “redirection loop
created”

here is the config code of my website.

server {
server_name www.xxx.com;
return 301 $scheme://xxx.com$request_uri;
}

server {
server_name xxx.com;
root /var/www/html/xxx/public_html;
index index.php info.php;
access_log /var/log/nginx/xxx.com/access.log;
error_log /var/log/nginx/xxx.com/error.log;

location / {
try_files $uri $uri/ /index.php?q=$request_uri;
}

rewrite /wp-admin$ $scheme://$host$uri/ permanent;

location ~ .php$ {
include fastcgi_params;
fastcgi_split_path_info ^(.+.php)(/.+)$;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
}

location ~*
.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|woff|woff2)$
{
add_header Access-Control-Allow-Origin xxx.com;

}

}

I can access php files properly like info.php. to check whether php is
working or not. however the problem part is wordpress.

when i try to load my wordpress site chrome shows an error saying
reduction
loop occur.

Any friendly advice will be highly appreciated.

Thanks,
Yousuf

Hello,

Muhammad Yousuf K. Wrote:

I can access php files properly like info.php. to check whether php
is
working or not. however the problem part is wordpress.

when i try to load my wordpress site chrome shows an error saying
reduction
loop occur.

I would think there’s a configuration somewhere (a config file or
database?)
in WordPress which redirect your example.com to www.example.com.
As I don’t use WordPress, I can’t help you better.

Best Regards

Posted at Nginx Forum:
https://forum.nginx.org/read.php?2,266118,266119#msg-266119

It sounds to me like wordpress believes that www is required and nginx
doesn’t want it.

I’d try commenting out the redirect server{} block and add the
server_name to the xxx.com one and see what you end up with in your
browser, then have a look through the wordpress settings to see what
it’s wanting in the address bar.

For my wordpress there seems to be 2 options under Settings/General,
“Wordpress Address (URL)” and “Site Address (URL)”.

On 12/04/2016 15:32, Muhammad Yousuf K. wrote:

}
}
}
when i try to load my wordpress site chrome shows an error saying reduction loop
occur.

Any friendly advice will be highly appreciated.

Thanks,
Yousuf


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

Links:

Thanks Steve and Alt for the hint. you point out the correct problem.
there
are two settings in wp-config.php which i change something like this and
it
worked.

from this

define(‘WP_HOME’,‘http://www.xxx.com’);
define(‘WP_SITEURL’,‘http://www.xxx.com’);

to this

define(‘WP_HOME’,‘http://xxx.com’);
define(‘WP_SITEURL’,‘http://xxx.com’);

now things are working as expected.

Thanks Alot :slight_smile:

MYK

On Tue, Apr 12, 2016 at 8:07 PM, Steve W.
[email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs