1

I made a mistake and changed the URL under settings -> General. After this Wordpress locked me out. I first added in the wp-congif.php file:

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

This appeared to have fixed the issue but only if I was logged into Wordpress. Users could not enter to the website and they have a forbidden message. My URL to visit my test site would redirect me always to my homepage, etc.

I also resetted the htcaccess file but nothing seems to do the trick. I finally uploaded a full backup of my site and the problem is still there, nothing works and the site is completely broken. Any ideas?

My current htaccess file looks like this:

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

# END WordPress
  • 1
    Do you have shell access to run WP CLI commands? When you say they receive a forbidden message, can you be more specific? Editing your question with a screenshots or quotes/snippets will help – Tom J Nowell Apr 6 '17 at 19:48
  • The get "Forbidden – You don’t have permission to access ‘/’ on this server." – Sergi Apr 6 '17 at 20:16
  • that sounds more like an Apache response than a WordPress response, check the /readme.html file if it loads ( if it doesnt then this is not a WP issue ), and the file/folder permissions – Tom J Nowell Apr 6 '17 at 23:51
  • It's probably a problem with the htaccess file right? – Sergi Apr 6 '17 at 23:52
  • What's the location of this .htaccess file? is it in your web root directory or is it in /guiacentros/ directory? – Fayaz Apr 7 '17 at 2:51
1

Fixed by adding a htaccess file to the root directory with this information:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/my_subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /my_subdir/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ my_subdir/index.php [L] 
</IfModule>

The main issues was Wordpress being installed in a subdirectory, so the root URL was "example.com/subdirectory" instead of "example.com". This htaccess comfiguration does redirect users properly.

Source: https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

0

Take a look in the wp_options table and check the values for siteurl and home - these are the values that would have been changed when you submitted the form, so you could change them back directly there. This may not be it but it's worth trying.

  • Is it ok to change this in example.com/wp-admin/options.php? I'm not sure how to access the wp_options. – Sergi Apr 6 '17 at 19:06
  • Sorry - I meant in your database - no, you shouldn't edit that file! Do you have access? I'm also assuming now you're back into the admin that you've tried just re-editing the URL under Settings -> General ? – Jonny Perl Apr 6 '17 at 19:09
  • I've re-uploaded an entire backup so the url should be valid, besides since I'm not locked from the site the Wordpress URL should be ok? I think I have to access the wp_config and I'm just not sure how...I just have the ftp details and wp log in details. – Sergi Apr 6 '17 at 19:14
  • @Sergi never modify WordPress core files under wp-admin or wp-includes, if you do, we can't diagnose the problem, and any solutions you come across may no longer apply – Tom J Nowell Apr 6 '17 at 19:49
  • I mean actually putting /options.php in the url, I have changed the home url there but as soon as I refresh the site any change is reverted. I'm now downloading phpMyAdmin so I can look at the wp_config file. But I have reuploaded the whole site with a backup...So any changes I could have made done there were reverted. – Sergi Apr 6 '17 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.