2015年9月14日 星期一

WordPress ERR_TOO_MANY_REDIRECTS

WordPress ERR_TOO_MANY_REDIRECTS


Got an WordPress ERR_TOO_MANY_REDIRECTS error when the first time visiting your new fresh installed WordPress website?
WordPress_ERR_TOO_MANY_REDIRECTS
Try following approaches, it maybe helps.

Case 1: WordPress was installed in an LAMP server

When you installed WordPress in an LAMP server, It means the Apache Server is your only httpd server, and it is responsible for the directory rewrite job for your WordPress website.

Step 1: Check Apache rewrite module is enabled!
Simply enable it in Ubuntu using following command:
$ sudo a2enmod rewrite
and you'll find a "rewrite.load" file in directory "/etc/apache2/mods-enabled" with an standard Ubuntu installation.
Step 2: Check .htaccess authorization
If your WordPress is installed in directory "/var/www/html", find the ".htaccess" file is in it with correct authorization. You could use following command to set the authorization:
$ sudo chown www-data:www-data /var/www/html/.htaccess
$ sudo chmod 644 /var/www/html/.htaccess
Step 3: Check rewrite authorization already granted to WordPress directory
If your WordPress is installed in directory "/var/www/html", edit the Apache configuration file:
$ sudo vi /etc/apache2/apache2.conf
and make sure you've granted the rewrite authorizaiton to the WordPress directory something like:
<Directory /var/www/html>
        AllowOverride All
</Directory>
Step 4: Verify .htaccess file again if you installed WordPress as an WordPress MU (WordPress Nework)
Go to the control panel of WordPress where you clicked to install WordPress Network previously, and make sure you've followed it's instruction to modify the .htaccess file.

Case 2: WordPress was installed in an LNAMP server

When you installed WordPress in an LNAMP server, it usually means you use Nginx server as an reverse proxy httpd server and proxy requests to Apache server. It will be more easy and flexible when you leave the rewrite job to Apache server.
Step 1: Verify every steps in case 1 are set!
Apache server still responsible for WordPress directory's rewrite job.

Step 2: Pass the WordPress directory request to Apache server from Nginx
By the Nginx's default configuration, your WordPress request will be trapped in loop of index.php page and root directory. Just pass the WordPress requests to Apache server and everything will be fine.
Try to add following codes as a final location search rule to your "/etc/nginx/sites-available/default" file if your Nginx is an standard installation in Ubuntu:
        location ~ ^/.* {
                proxy_pass http://localhost:8080;
                include proxy_params;
        }
The http://localhost:8080 in the example should be changed to http://YourServerDomainName:YourApachePortNumber.

Hope this helps!
Relative article

沒有留言:

張貼留言