WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] htaccess rewritten after clicking "permalinks" in admin sidebar (7 posts)

  1. FeralReason
    Member
    Posted 10 months ago #

    We installed a WP blog on an existing site - similar to many I've done: GoDaddy hosting, Linux Apache server, WP 3.5.1. The blog is in a subdirectory "www.mysite.com/blog".

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

    When I log in to admin and simply click on the "Permalinks" link in the left sidebar (without changing anything) the .htaccess file is rewritten to this (took some trial & error to determine this):

    # BEGIN WordPress
    # END WordPress

    After this, trying to access the blog ("www.mysite.com/blog") results in the chrome message "This webpage has a redirect loop". Also when I try to log in using "www.mysite.com/blog/wp-login.php" it does not accept my login but issues no error.

    Once I restore the .htaccess file back to its original state, everything runs fine. Though, unfortunately, I obviously cannot change Permalinks settings with this situation :P

    Tried to recreate this problem on another site I just installed (also 3.5.1) and the problem did not occur.

  2. kmessinger
    Volunteer Moderator
    Posted 10 months ago #

    What is the permalink setting you want to run?

  3. FeralReason
    Member
    Posted 10 months ago #

    Postname.

    At first I thought actually changing the setting was causing the .htaccess code to be deleted (changing permalinks can cause .htaccess changes) but the puzzle is that the .htaccess file becomes altered before I ever get into the settings. It happens when I click on the "Permalinks" link in the left sidebar. Makes no sense but I ran several trials to confirm it. After each trial I had to go into FTP, edit the .htaccess and put the code back in that was deleted. Correlation at least... whether it's cause and effect I don't know :P

  4. kmessinger
    Volunteer Moderator
    Posted 10 months ago #

    Set the permissions for the htaccess to 444. That way when you change the permalinks you will get a message showing you what you must manually set the htaccess file to.

  5. FeralReason
    Member
    Posted 9 months ago #

    kmessinger - Thanks much. Sorry for long delay - I was on vacation.

    I just tried your suggestion. As soon as I click on Common Settings -> PostName (radio button) and then click "Save Changes" it puts me back into the login screen (as before) and will not allow me to log in.

    No message on proper PermaLink settings appears and the .htaccess file is rewritten, deleting all code as before. At this point I can't even access the blog online until I restore the .htaccess file back to what I described above (also as before). Going back to the main site and clicking on the link to the blog (or trying to access it through its URL) again results in the message "This webpage has a redirect loop".

    Since this blog is in a subdirectory of the root, I also checked the Root's .htaccess file. It is identical to my other installations (that work).

    My best theory (at this point) is that setting Permalinks attempts to rewrite the .htaccess file but only goes half way -- deleting the contents but not adding the necessary code. However, I have no theory as to why this might be happening.

    Any other suggestions or theories would be welcome !

  6. kmessinger
    Volunteer Moderator
    Posted 9 months ago #

    Have you tried:

    - deactivating all plugins to see if this resolves the problem. If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    - switching to the Twenty Eleven theme to rule out any theme-specific problems.

    - resetting the plugins folder by FTP or PhpMyAdmin. Sometimes, an apparently inactive plugin can still cause problems.

    - re-uploading all files & folders - except the wp-content folder - from a fresh download of WordPress.

  7. FeralReason
    Member
    Posted 9 months ago #

    Thx for the response. I think I've solved the problem. Although I haven't identified the cause, I've at least isolated it down to the root directory's .htaccess. (Recall that I have the Blog located in a subdirectory of the website's root -- so there is a root .htaccess and a /blog/ .htaccess.)

    So (for the benefit of posterity) here is what worked:
    1) Rename the ".htaccess" in the root directory (to something like ".OLDhtaccess".
    2) Log into the WP admin area and set the Permalinks as desired.
    3) Test (everything works appropriately.)
    4) Rename the ".OLDhtaccess" back to ".htaccess".

    I haven't had the time to test the root .htaccess line by line -- and it would disrupt the client's site too much to do so now -- I'll save that for some future opportunity. (The curious thing is that I have two other virtually identical .htaccess files with very similar sites working fine.)

    Didn't get around to deactivating plugins - altho there is only one active plugin - sharebar. So no plugins (such as SEO plugins) that might play with .htaccess.

    For now I'm marking this as "resolved" tho not fully understood :)

    Thx for all the responses!

Reply

You must log in to post.

About this Topic