75 votes

WordPress wp-admin https redirect loop

I had a similar problem and just added the following snippet to my wp-config.php: /** SSL */ define('FORCE_SSL_ADMIN', true); // in some setups HTTP_X_FORWARDED_PROTO might contain // a comma-...
Elias's user avatar
  • 851
31 votes

Changing permalinks gives me 404 errors on nginx

I'm using wordpress multisite with custom permalink setting: /%category%/%postname%/ /etc/nginx/site-available/domain.conf On server{ location / { try_files $uri $uri/ /index.php?q=$uri$args; } ...
Domi's user avatar
  • 411
18 votes

WordPress wp-admin https redirect loop

As I do not have the comment privilege yet, I will post this addition as another answer: The solution proposed by Elias, to add the following to wp-config.php, did the trick for me: /** SSL */ ...
Michael Jung's user avatar
11 votes

Changing permalinks gives me 404 errors on nginx

Had to add this piece of code to both the /sites-available/your-settings-file and /sites-enabled/your-settings-file: server { [...] if (!-e $request_filename) { rewrite ^.*$ /index.php last; } [...
Angelo Reale's user avatar
11 votes
Accepted

Nginx - Prevent Access to Debug file

I've frequently seen this used in Apache 2.2: <Files "debug.log"> Order allow,deny Deny from all </Files> but that's deprecated in Apache 2.4: The Allow, Deny, and Order ...
birgire's user avatar
  • 67.1k
8 votes

WordPress wp-admin https redirect loop

Another version for the books, just add this to the top of wp-config.php Reason is that there could be load balancers or something that does not pass along the proper https value, so you have to grab ...
Timo Huovinen's user avatar
7 votes
Accepted

WordPress tips for speed and performance

I work with several large WordPress sites, news sites specifically, that have thousands of posts and thousands of visitors (300k/day). With the stuff below, and a well coded theme, with well written ...
Tyler Johnson's user avatar
6 votes
Accepted

Installation failed: Could not create directory - CentOS 7

SELinux was the problem. Its enforcement was, for lack of a better term, overriding the file permissions and keeping Wordpress from writing to any of the files. To solve the issue, I did the ...
Kyle Martin's user avatar
5 votes
Accepted

Nginx FastCGI_Cache Vs PHP Caching

Nginx is really good at concurrency (PHP not so much) so you should try a bit more than 180 requests per second. Maybe 500, or 1000 depending on your server resources and network throughput. The ...
kovshenin's user avatar
  • 2,583
5 votes

REST API parameters not working with nginx

If your virtual host looks like this: try_files $uri $uri/ /index.php$args; change it to this: try_files $uri $uri/ /index.php$is_args$args; Adding $is_args (which will print a ? character if ...
Michele's user avatar
  • 202
5 votes
Accepted

Why can't /wp-login.php be load balanced?

A few things to check on: Review wp_salt. Make sure all of the web servers are running on the same set of salts in the wp-config.php file. Ideally, these should be mirrored from a single location. ...
jaswrks's user avatar
  • 851
5 votes
Accepted

Wordpress redirect loop on nginx + apache reverse proxy

Issue was caused by nginx serving example.com/index.php while Wordpress was redirecting to example.com/, thus causing a redirect loop. This is the working config I used to fixed the redirect loop: ...
Capy's user avatar
  • 81
4 votes

WordPress - admin-ajax.php returns 502 Bad Gateway

I had similar problem on wordpress site. add these lines inside http block of /etc/nginx/nginx.conf file. fastcgi_temp_file_write_size 10m; fastcgi_busy_buffers_size 512k; fastcgi_buffer_size 512k; ...
Tharindu Wickramasinghe's user avatar
4 votes

WordPress wp-admin https redirect loop

5 year old Question... Okay, I had this error, after installing my SSL Certificate and changing all links that were http to https using the wp-cli.phar found here. I tried various configurations and ...
Ricky's user avatar
  • 141
4 votes

Wordpress installation in subfolder not working with nginx

The problem resolved, I just need to add a location entry as follow: location /new { try_files $uri $uri/ /new/index.php?$args /new/index.php?q=$uri&$args; }
Ivan Slaughter's user avatar
4 votes

Plugins fail to update: Download failed. A valid URL was not provided

you can use this code in functions.php to avoid ssl check : add_filter( 'http_request_args', function ( $args ) { $args['reject_unsafe_urls'] = false; return $args; }, 999 );
Mahdi Akrami's user avatar
3 votes

Block PHP Files Nginx

Ok found the answer. You need to put this directive above the location: location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } The ...
JoaMika's user avatar
  • 668
3 votes
Accepted

Why "Settings->Permalinks" creates .htaccess file on nginx server?

WordPress tries to detect the webserver's type by peeking into the global $_SERVER['SERVER_SOFTWARE'] variable. The Apache check is: $is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== ...
birgire's user avatar
  • 67.1k
3 votes
Accepted

How to setup 301 redirects for multiple query string URLs?

From doing some research, I'd recommend trying out this plugin: Redirection. This plugin allows you to manage 301 redirections. I played around with the settings and they allows regular expressions ...
Ethan O'Sullivan's user avatar
3 votes

Limit file downloads to logged in users (WP + Nginx)

a slight variant of this worked better for me location /wp-content/uploads/ {if ($http_cookie !~ "wordpress_logged_in") { return 403; } } This prevents all direct access to the ...
Mikcomac's user avatar
3 votes
Accepted

Wordpress behind Proxy - Mixed Content

Please take a look at Administation Over SSL, particularly the "Using a Reverse Proxy" section.
hcheung's user avatar
  • 339
3 votes
Accepted

ERR_TOO_MANY_REDIRECTS status 302, how to configure NGINX locations to work with AWS ALB?

The problem happens because of the way AWS ALB works, or at least the way mine is setup (which seems to be quiet common practice to be fair), the Loadbalancer listens on HTTPS:443 and forwards to the ...
punkbit's user avatar
  • 161
2 votes

Wordpress redirecting connections on port 8080 to 80

Same problem. In my situation, I set the server port at 3030, to accommodate other servers. Anyway, without having to add any code to any functions.php files, I solved the problem by changing the site ...
seebiscuit's user avatar
2 votes

Is it safe to give wordpress directories ownership to www-data?

No, it is not safe as it means that any security breach might end up in your code being changed. Alternatives: There is nothing wrong in using SFTP to upload changed plugins. If it is something that ...
Mark Kaplun's user avatar
  • 23.4k
2 votes

How to test drive WordPress on VPS with LEMP stack before going live?

WordPress doesn't care much about IP address, it is mostly sensitive to domain name it is accessed by. In your case you can access the test site if you make your local machine resolve domain to its ...
Rarst's user avatar
  • 99.7k
2 votes
Accepted

Wordpress with Photocrati Theme keeps resetting site URL - help solving underlying problem

If this is done via WP Options API (as opposed to direct SQL query on database) you can use hooks to log it. Something along the lines of (not tested, make sure it works under normal option save ...
Rarst's user avatar
  • 99.7k
2 votes

wp-json/ return 404, but wp-json/wp/v2/ works fine on my nginx server

Just ran into the same issue on an nginx only (no Apache) WordPress blank install 4.7.2 site. The base /wp-json/ & index.php?rest_route=/ URLs showing rest_no_route 404, but all the /wp-json/wp/...
user113522's user avatar
2 votes
Accepted

Possible to configure nginx to ignore cache for logged in users in certain roles only?

Here is what I ended up doing: // Set disable cache for certain roles add_action('init', 'add_custom_cookie_admin'); function add_custom_cookie_admin() { if ( is_user_logged_in() ) { $current_user = ...
Stephen's user avatar
  • 951
2 votes
Accepted

Infinite loop behind SSL proxy on non-standard port

Changing proxy_set_header Host $host; to proxy_set_header Host $http_host; fixed the issue. (source)
That Brazilian Guy's user avatar
2 votes
Accepted

Difference between these two nginx try_files statements for WordPress?

As far as I know, WordPress does not require a q= parameter set to the original request (the pretty permalink). So in the second option, the q= parameter will be silently ignored. According to the ...
Richard Smith's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible