The Ultimate Guide To When Wordpress Permalinks 404



 The 404/Not Found error message is one of the most hated screens on the Internet; it indicates that though you, the browser, were able to communicate with the server, the page you need was not delivered either because it was not found or because the server for some reason was configured to not fulfill the request (which is happening in some countries with pages containing illegal content).


The page you actually see is not generated by your computer; instead, it is a special page on the server you've tried to contact. Many web sites create their own special 404 pages either for artistic reasons, or because the site owner wants to put specific data, like contact or redirect information, on the page. In Apache, having your own special 404 page is as simple as modifying the .htaccess file. (The only caveat: the page must be larger than 512 bytes or IE will not display it.)


In most cases, the 404 error comes up when a page has been moved or deleted from a site. However, in the case of WordPress, an annoying bug can cause permalinks to point to the 404 page instead of the page you want to have it bring up.


How Do WordPress Permalinks Work?


Permalinks are permanent URLs generated to point to your individual weblog posts, categories, and weblog lists. Other bloggers will use a permalink to point to your post from their own articles, or you can send links to other people via a permalink. When they are linked to an individual post, the URL is supposed to be permanent, not dynamic (changing).


The three types of permalinks WordPress delivers are the Default (aka "Ugly") form, mod rewrite ("Pretty"), and PATHINFO ("Almost Pretty").


Default links are formatted according to the default settings of a new WordPress install, and will work on all server environments. It looks like this: http://example.com/?p=N , N being a number. It is neither neat nor elegant, but it does the job. Pretty mod rewrite links look more like this: http://example.com/yyyy/mm/dd/post-name/ . These permalinks require Apache's mod_rewrite module, and won't work on other server types. PATHINFO permalinks look like this: http://example.com/index.php/yyyy/mm/dd/post-name/ , and will work on other server types besides Apache.


Because you're going from a dynamic to a fixed environment with your permalinks, a variety of things can go wrong with them. For instance, if your server includes Frontpage Extensions, permalinks will not function at all without doing a manual fix. Without this fix, any changes to the permalinks section from the WordPress admin interface will corrupt the Frontpage server extensions because it interferes with the .htaccess file.


Long permalinks can get chopped off as well, with only part of it working properly or with the entire link disabled. This will cause a 404 error to be generated – but not because there's something wrong with your permalink, rather because the title is too long. You can fix it by editing your .htaccess file to add a line:


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


You can also make a habit of posting URLs with angle brackets () on either end. Most email and other problematic software won't truncate URLs formatted this way.


Permalink Structure in WordPress


When your links don't work, it's often because you didn't update your Permalink structure. Every time you add a new static page to your WordPress files, you must generate and update new rules to the .htaccess (which in newer versions is taken care of through the admin control area). If you don't get a page returned at all, even a 404, and you use PHP 7.2 or  with Apache 2.4, you should look that up in the PHP bugs and issues pages. This is a specific known bug.



When you're creating permalinks, another strange thing can happen: your WordPress blog must start the process of creating a permalink before it knows whether or not the page you're creating one for actually exists. If it doesn't, too late – your link is already pointing at a 404 page. To repair this, you need to include a 404 direction in the header of your .htaccess file so that your rewrite conditions allow for a not-found error, and simply eliminate that page from your permalinks task. Try adding the following line above the WordPress rewrite rules, outside of #BEGIN Wordpress[...]#END Wordpress. Some plugins will overwrite this part if you edit the permalinks structure if it's in the wrong place.


ErrorDocument 404/index.php?error=404?


Another solution is to use this following:


ErrorDocument 404/foo/index.php?error=404


foo = the directory you are using as a blog. The structure should be like this:


/foo/%category%/%postname%/


If you call a nonexistent directory, however, you're still going to get that 404 permalink.


You can automate your permalinks tasks with several plugins, though. The Ultimate Tag Warrior (UTW) has gotten some good reviews, especially for search-engine sensitive pages. Google Sitemaps is a good plugin as well.


One more thing: if you use the xampp setup, your WordPress permalinks won't work at all in the default installation..


The ultimate solution is actually to install WordPress 5.8.2; this new version has repaired the permalinks problem as well as a number of other problems.


Always double-check all your pages before you start working with permalinks, and after you've permalinked them. In some cases, you may have to delete all the permalinks and start over, but in most cases just taking a look at what you're telling your server to do will prevent you from making a lot of stupid mistakes.


1/Post a Review/Reviews

Post a Comment