EasyEngine Wordpress non-www to www

I tried adding this to my server config file. to redirect non-www to www and it crashed my site… It says too many redirects. How do I fix this

server { server_name example.com www.example.com; return 301 $scheme://www.example.com$request_uri; #this is the line i actually added }

cd /var/www/domain.com/htdocs
wp option set home http://www.domain.com
wp option set siteurl http://www.domain.com

I got alot of fatal errors…

PHP Warning: include_once(/var/www/example.com/htdocs/wp-admin/includes/file.php): failed to open stream: No such file or directory in /var/www/example.com/htdocs/wp-content/plugins/searchwp/includes/class.debug.php on line 10 ect.ect.

Well, I don’t know what to do. Let’s stand by someone else to make a suggestion.

I don’t think these errors are related to the line you added, but just to be sure comment it out and then see if errors will stop. if not try to disable all plugins and if errors are gone you will know that one of your plugins is causing the issues. Start enabling them one by one till you get the error again this way to identify the problem plugin.

But it looks like ‘searchwp’ pluign is causing the issue, try first to disable it.

You have server_name example.com and www.example.com, both returning a 301.

Of course there will be a redirect loop.