WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Permalinks stuck on default settings (21 posts)

  1. karenbatten
    Member
    Posted 1 year ago #

    Hi There,
    thanks in advance for your help.
    I have read many posted but unfortunately I don't really follow. I have tried some things but nothing seems to be working.

    I have created a new .htaccess file.
    Originally it had this code in it

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    From the forums I added this code

    # 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

    When I went back to the .htaccess file this code had disappeared and only the below was there.

    # BEGIN WordPress
    # END WordPress

    I am making all these changed under the cpanel x

    Under wordpress I have been going to settings > permalink and when I select the custom setting it just returns to the default and says the permalink structure updated, but it hasn't.

    Thanks Karen

  2. Tara
    Member
    Posted 1 year ago #

    Does the default setting work?
    If it does, then try reviewing Using_Permalinks before setting a custom permalink structure again.

  3. karenbatten
    Member
    Posted 1 year ago #

    Yes default setting does work.
    I have read Using_Permalinks but I don't understand all the instructions.
    I'm thinking it has something to do with this maybe?

    Pretty permalinks are available under:
    Apache web server with the mod_rewrite module
    Microsoft IIS 7+ web server with the URL Rewrite 1.1+ module and PHP 5 running as FastCGI
    Microsoft IIS 6+ using ASAPI_Rewrite
    Lighttpd using a 404 handler or mod_rewrite (see See Also)

    But I don't know how to find out which one applies to me.
    I can't seem to find the httpd.config file and don't know if I have one...
    Sorry I just don't understand the instructions.

  4. Jesin A
    Member
    Posted 1 year ago #

    Your environment must be "Apache web server with the mod_rewrite module"

    First clear whatever you did to the .htaccess file. It should be complete empty.

    Then instead of a custom structure choose a "Common Setting" such as "Post name" or "Day and name" and see if it works.

  5. karenbatten
    Member
    Posted 1 year ago #

    Thanks for you suggestion.
    I have emptied the .htaccess file to be completely empty.
    When I test changing the permilinks to other settings everyone produces the below error.

    Not Acceptable
    An appropriate representation of the requested resource /wp-admin/options-permalink.php could not be found on this server.
    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

  6. Tara
    Member
    Posted 1 year ago #

    /wp-admin/options-permalink.php could not be found on this server.

    check and see if this file is there

  7. Jesin A
    Member
    Posted 1 year ago #

    @Tara the file does exist, it is returning a 406 Not Acceptable Error.

    @karenbatten I think your host uses mod_security which is causing the issue. Edit your .htaccess file and place the following in it

    <IfModule mod_security.c>
    SecFilterEngine Off
    SecFilterScanPOST Off
    </IfModule>

    This will disable mod_security for your WordPress installation. Then try choosing a permalink structure.

  8. karenbatten
    Member
    Posted 1 year ago #

    Thanks Jesin and Tara for your suggestions.

    Tara the file is there.

    Jesin, I make the change to the .htaccess file and this error still appreared.

    Not Acceptable
    An appropriate representation of the requested resource /wp-admin/options-permalink.php could not be found on this server.
    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

  9. Jesin A
    Member
    Posted 1 year ago #

    Looks like your host doesn't allow overriding mod_rewrite rules. So this has to be done manually.

    Open phpmyadmin, open your WordPress database, select the SQL tab and run the following query

    UPDATE wp_options SET option_value='/%postname%/' WHERE option_name='permalink_structure'

    Then edit your .htaccess file and place the following.

    # 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
  10. karenbatten
    Member
    Posted 1 year ago #

    Thanks again.
    Ok so I have opened 'phpmyadmin' in cpanels.
    I aimed to login to the database or SQL section but this error came up
    #1045 Cannot log in to the MySQL server

  11. Jesin A
    Member
    Posted 1 year ago #

    Create a file named perma.php in the same directory as the wp-config.php file (usually public_html/) with the following code.

    <?php
    require_once 'wp-config.php';
    mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
    mysql_select_db( DB_NAME );
    echo ( mysql_query( "UPDATE wp_options SET option_value='/%postname%/' WHERE option_name='permalink_structure'" ) ? 'Success' : mysql_error() );
    ?>

    Access this file and you'll see "Success", then add the .htaccess rules if they aren't present.

    Delete perma.php after this is done.

  12. karenbatten
    Member
    Posted 1 year ago #

    Ok so I have placed the above code in a new file called 'perma.php' in teh public_html/ folder where the wp-config.php file is.

    I don't understand the next step
    Access this file and you'll see "Success", then add the .htaccess rules if they aren't present.

    I have looked in the .htaccess file and this code is there

    # 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
  13. Jesin A
    Member
    Posted 1 year ago #

    Did the file print "Success" when you accessed it? Then you are good to go. Permalinks must be working now.

  14. megadeth23
    Member
    Posted 1 year ago #

    If it helps any, I was having an issue getting permalinks to work as well. I just spent a good amount of time reading articles about permalinks. I came across one (sorry, dont remember where it was) that showed a permalink address as http://www.domain.com/index.php/blog-name. but when I checked my address bar to see where it was getting directed to, it didn't have the index.php portion in it.

    just for the hell of it, I selected custom structure and entered: /index.php/%postname%/

    Surprisingly this actually worked. I think wordpress needs to have that issue fixed. Hopefully this will help you out

    PS i did not do anything with any .htaccess files or anything like that. what you see above is all I did

  15. megadeth23
    Member
    Posted 1 year ago #

    just an update,

    here is the link to the article I found
    http://codex.wordpress.org/Using_Permalinks

    and the blurb that pointed me in the direction I went

    "Otherwise, they are the same as the "pretty" mod_rewrite permalinks, and are similarly flexible. Anything that mod_rewrite permalinks can do, PATHINFO permalinks can do, with the help of that /index.php part. "

  16. Jesin A
    Member
    Posted 1 year ago #

    @megadeth23 OP's issue is completely different. Mod_security or some other Web Application Firewall is stripping out POST requests which contain the '%' symbol. From the first post of OP

    Under wordpress I have been going to settings > permalink and when I select the custom setting it just returns to the default and says the permalink structure updated, but it hasn't.

  17. karenbatten
    Member
    Posted 1 year ago #

    Thanks Megadeth23 for your suggestions but I have tried many things and this is something different like Jesin mentioned.

    Jesin, Sorry I'm having trouble following.
    I have looked at the .htaccess file and it is empty again except

    # BEGIN WordPress
    # END WordPress

    the perma.php has

    <?php
    require_once 'wp-config.php';
    mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
    mysql_select_db( DB_NAME );
    echo ( mysql_query( "UPDATE wp_options SET option_value='/%postname%/' WHERE option_name='permalink_structure'" ) ? 'Success' : mysql_error() );
    ?>

    I don't know how to print these files to find the work 'success'. I have checked the permalinks and they are still the default and if I make the change to custom structure or post name and this error came up

    Not Acceptable
    An appropriate representation of the requested resource /wp-admin/options-permalink.php could not be found on this server.
    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

    Thanks so much for your help...

  18. Jesin A
    Member
    Posted 1 year ago #

    Yes just access the perma.php file on your browser like this

    http://www.example.com/perma.php

    It'll display the word "Success"

  19. karenbatten
    Member
    Posted 1 year ago #

    Thanks heaps! that worked!

  20. karenbatten
    Member
    Posted 1 year ago #

    topic resolved

  21. Jesin A
    Member
    Posted 1 year ago #

    Great to hear that!

    Contact your host and ask them to disable mod_security or any other WAF for the /wp-admin directory. Else you'll run into a lot of problems when saving settings.

    And also delete the perma.php file immediately.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.