2
votes

Have a strange error that has recently popped up that I am struggling to resolve.

I have a wordpress install using the sub domain method:

www.example.com/wordpress

in my root directory I have .htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

And my index file:

<?php
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );

home is set to: www.example.com url is set to: www.example.com/wordpress

When I try and access the admin at: www.example.com/wordpress/wp-admin I get the error: Sorry, but the page you are looking for could not be found.

This is not a new install of Wordpress and this issue only recently happened after an auto update.

How do I go about bug testing this?

2
Try to login with : www.example.com/wordpress/wp-login.phpdaniyalahmad
I did try, unfortunately it does not work.HappyCoder
Paste your URL here.daniyalahmad

2 Answers

2
votes

You're using a subdirectory installation (rather than a subdomain installation); as such, your .htaccess file doesn't belong in the root directory - it should be in your /wordpress/ directory, along with the rest of your installation.

In addition, your .htaccess needs to be edited to account for the fact that it resides in a subdirectory:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress

You should also remove the wordpress/ part from your index.php file. The PHP magic constant __FILE__ essentially means 'relative to this file', so if your index.php file is in /wordpress/, it's effectively saying 'look in /wordpress/wordpress/ for wp-blog-header.php`.

So amend that line in your index.php file to this:

require( dirname( __FILE__ ) . '/wp-blog-header.php' );

...and everything should work as expected.

2
votes

The fix for this was relatively simple. After checking the apache logs I noticed the following error each time I attempted to access the admin URL:

SoftException in Application.cpp:256: File "/home/example/public_html/wordpress/wp-login.php" is writeable by group

The permissions for this file were set to: 644 which in theory should work. I read on the Wordpress Codex that permissions should either be 644 or 640:

https://codex.wordpress.org/Changing_File_Permissions

I changed the wp-login.php file to 640 and my problem was resolved.

I think this errors came about not due to a wordpress update but rather a server update. This is likely a common problem for Cpanel managed servers.