9 WordPress Permalinks Issues with Solutions – WebNots

Source: 9 WordPress Permalinks Issues with Solutions – WebNots

Permalinks is a permanent link structure for your entire WordPress site to make URL of each post / page in a meaningful descriptive manner instead of using post id. Permalinks can be easily setup under “Settings > Permalinks” in your WordPress admin dashboard. Its well and good if you can simple activate permalink for your site, this article deals with various WordPress permalinks issues and solution for those issues.

Permalink Issues in WordPress

One of the major reasons for permalinks not working in WordPress is the wrong directives setup in .htaccess file. Therefore, first we will explain all htaccess related issues and then cover other issues.

1. htaccess File Issues

Activation of pretty permalinks needs WordPress to update your .htaccess file to modify mod_rewrite module of apache server. If there is an issue related to .htaccess file then you will see an error something like “If your .htaccess file were writable, we could do this automatically, but it isn’t…” There are two possible issues can arise here:

1.1. No .htaccess File

If .htaccess file is not available in your WordPress installation it will be automatically created when you activate permalinks. Or you can create a text file something like “test.htaccess” and upload it to your site’s root directory. Then change the file name to .htaccess and the following rewrite code using FTP or hosting control panel.

# 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

1.2. No Write Permissions and 404 errors

If you have an .htaccess file but still see an error then the possible reason could be missing file permission. If WordPress do not have write permission to update your .htaccess file then you will not be able to setup permalinks for your site and accessing your posts URLs may return 404 page not found error . In this case you can either modify file permission settings through FTP or using hosting control panel to something like 666.

Once you modified the file permission then go back to admin dashboard and change the permalinks settings to default and save changes. Again change the settings back to the one you needed and save changes. In this way WordPress will delete previous rewrites and create new rewrites and update your .htaccess file.

1.3. No Access to .htaccess File

Some hosting companies may not allow viewing or modifying .htaccess file if you have installed WordPress through their installation process in root directory. In this case, if there is an option you can manually install WordPress by downloading installation package from wordpress.org site.

Or you can install WordPress in a subdirectory like http://yoursite.com/blog/ to access .htaccess file, which will be generated in blog subdirectory.

Points to Note:

  • .htaccess file will be located in your root directory, that is “/public_html” if you installed WordPress on root directory.
  • Do not forget to reset file permissions back to 660 or 644 once permalinks is successfully activated for your site. This will prevent someone having access to your .htaccess file.
  • Clicking on save changes button without any changes on permalinks settings screen will not have any impact since new rewrites will not be generated for existing selection.

1.4. Viewing .htaccess File

FTP programs by default hide .htaccess file, hence you may need to enable this option to view the file. Many users misunderstand this and assume there is no file available on the server, however it is hidden by default.

Showing Hidden Files in FileZilla
Showing Hidden Files in FileZilla

2. Using Long URLs

When a long URL link is used in email or comments, sometimes linked section will be truncated. For example:

https://yoursite.com/2014/10/31/this-is-a-long-url-to-be-sent-through-email/ will be having a link partially and clicking on which will result in a 404 error. In order to correct this add the below code in your .htaccess file:

RewriteRule ^post/([0-9]+)?/?([0-9]+)?/?$ /index.php?p=$1&page=$2 [QSA]

Note: Use < and > to send URL links in email like <http://yoursite.com/your-url> to avoid truncation issue.

3. AllowOverride Directive is Disabled

If the AllowOverride is set as “None” inside httpd.conf file of your Apache server then server will not read your .htaccess file. Hence permalinks will not work as expected. Ensure AllowOverride and FollowSymLinks are enabled in your httpd.conf file by adding the below code:

<Directory />
Options FollowSymLinks
AllowOverride All 
</Directory>

If AllowOverride is not set as “All” then it should have “FileInfo” as directive.

4. Permalinks Page Navigation Not Working

If you noticed any linked page/post is not working as expected and returning 404 error or blank content then follow the below steps:

  • Backup your existing .htaccess file and delete all the content inside the file.
  • Go to “Settings > Permalinks” in your WordPress admin dashboard, select default option and click on “Save Changes” button.
  • Again select the required option and click on “Save Changes” button.
  • This will regenerate fresh rewrite rules and update in your .htaccess files.
  • Add additional content from the backed up file.

You also can completely delete and create a new .htaccess file in this case.

5. Using Restricted Reserved Names for Post or Pages

It is not known to most of the WordPress users that WordPress has restriction to use certain names in taxonomies. For example, using a top level page name of “preview” will result in all child pages attached to this parent “preview” page to return 404 error when permalinks is used.

Ensure not to use reserved terms for your page URLs.

6. Plugin Compatibility

Some plugins may conflict with permalinks settings and not allow enabling permalinks. Deactivate all plugins and try to activate permalinks and then you can activate one by one to find which plugin is causing issue.

7. Conflict with Archive URLs

If you use a custom structure like “%year%/%monthnum%/%day%/” for your post URLs it will conflict with the archival URL for that day. It is recommended to use custom structure suffixed with post id or post name to avoid interpretation issues.

8. Permalinks Error on Local Installation

If permalinks settings is not working in any of the local installation used with MAMPWAMP or XAMPP then you need to enable “mod_rewrite” module so that WordPress can access your .htaccess file.

9. Using Category in Permalinks Custom Structure

When you use %category% tag in the custom structure of your permalinks and assign more than one category to that post, WordPress will show the first category in alphabetical order in the post URL. This is the same process for sub-categories as well which will result in adding less appropriate category to URL and leaving the main category which you wanted to be part of the URL. The solution here is to use plugins to choose the required category when you assigned more than one category to a post.

Wrapping Up

We hope this article helped you to understand various problems raised with permalinks structure in WordPress. When you face a problem, we recommend you to setup your site in maintenance mode and troubleshoot by following the above solutions. Most importantly, make sure that you are not changing the permalinks structure after setting up initially. This will affect the URLs and hence the SEO of your site.

Leave a Reply

The maximum upload file size: 500 MB. You can upload: image, audio, video, document, spreadsheet, interactive, other. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here