Question

wp-Admin Goes To 404 - wp-admin.index Does Not

Hey everyone,

I’m new to Digital Ocean / VPS, and just moved from shared hosting. I’ve got a pretty decent handle over everything the last few days, but I have an odd issue I can’t solve now. I’m currently running a LEMP stack.

For whatever reason, my site.com/wordpress/wp-admin page always brings up a 404, which with my current setup redirects to site.com/oops. No other url has an issue, and I can even go to site.com/wordpress/wp-admin**.index**, but without the .index, it doesn’t work. The login by default doesn’t add index, so whenever I try to log in I get a 404.

My only guess as to what’s going on, is that I messed something up when putting Wordpress in its own directory. My setup is currently in var/www/site/public_html/wordpress/, and it’s on it’s own server block. On Shared hosting / apache, I simply had to add a bit of code to the .htaccess file, but I read with nginx I had to edit my server block within the sites-available directory. I then copied the index.php file from wordpress to the root, and added the header bit (as I’ve always done for this setup). Here’s what I found / added, is this correct?

server {
	listen 80 default_server;
	listen [::]:80 default_server ipv6only=on;

	root /var/www/anightinburlington.com/public_html;
	index index.php index.html index.htm;

	# Make site accessible from http://localhost/
	server_name anightinburlington.com www.anightinburlington.com;

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		# try_files $uri $uri/ =404;
		try_files $uri /wordpress$uri/ /wordpress/index.php?q=$uri&$args;
		# Uncomment to enable naxsi on this location
		# include /etc/nginx/naxsi.rules
	}


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

If you’re want to serve WordPress from a subfolder, you’ll want change your Nginx configuration from:

    location / {
        try_files $uri /wordpress$uri/ /wordpress/index.php?q=$uri&$args;
    }

to:

location /wordpress/ {
    index index.php;
    try_files $uri $uri/ /wordpress/index.php?q=$uri&$args;
}

Let us know how it goes!