I’ve had a few site problems whereby my host Site 5, said I was using too many resources and crashing their systems. Naturally, I was appalled. I traced this to a variety of plugins plus some errors in php files which must have arrived either during the periodic updates or during editing. These were errors whereby extra text (either blank space or a carriage return to be precise) were added to the end of the php file, which usually makes it fail. This a is a Google search on the main error I received,
Warning: Cannot modify header information – headers already sent … ( This is then followed by error details; usually error on line xx, repeated several times for a variety of xx)
After battling for some time, I just gave up, exported my database key tables (things like posts, comments, etc but omitting plugin inserted tables and the very large options table which I deemed to be very bloated after over five years of continuous WordPress operation…!) and re-installed WordPress as a fresh installation on my server.
Weird Permalink Problem Following Clean Install of WordPress
This is where the weird problem arose….
When one installs WordPress for the first time, permalinks are set to the default – so this current post would be:
For SEO reasons and for many years I’ve used the format shown in the screenshot from my site shown left. This current post will thus appear as:
It’s a “Custom Structure” and the .htaccess file is updated automatically by WordPress when you set it. You’ll see it’s set to:
Now, on firing up a post, say this one,
the actual web address I was taken to was:
http://strangelyperfect.tv/%post_id%/victory-or-is-it-victory-jesse-willms-surrenders-all-to-ftc-onslaught/ (error shown in bold)
…which redirected to the homepage of the site, http://strangelyperfect.tv/ This was not what I was expecting! So I played with the slashes, went back to original simple permalink structure, tried some of the suggested structures – and they all worked!
A custom structure of /%postname%/ worked as well, but not the one I wanted and have used for years.
Weird. So naturally, I tried Google.
Permalink Redirection Problem Solved.
There’s a lot on the web about this. Most is about getting .htaccess right with permissions and the code. But mine was okay, as were all the other suggestions to try.
He suggested adding index.php between the domain name and permalink structure. So my custom structure changed to:
WordPress added a leading slash on the save and the website worked! WAHAY!
However, the best is yet to come….
I thought that the URL was now not pretty, in fact, it was pretty ugly. The URLs were now being shown like:
So I removed the index.php and reset the custom structure to what I wanted – /%post_id%/%postname%/
It worked! WAHAY! All posts’ URLs redirecting how I wanted!
I’ve no idea, actually. I’m suspecting some caching, somewhere down the great inter-tubes in the sky, but apart from that…………..?
- Was it my server? Dunno.
- Was it DNS caching? Dunno.
- Was it ISP caching? Dunno
All I know is that it’s working now, and the Happiness Engineer’s suggestion sent me on my way, happy.
Postscript – added 22/11/2015
Since this time, I have not had to use the index.php fix, and the permalinks are all working correctly. The flip-flip of adding and removing the fix….just seemed to work!
- WordPress Permalink Redirection working – but still 404 Error – Object not found (stackoverflow.com)
- SEO and 404 redirect (oldwildissue.wordpress.com)
- Changing WordPress Permalink Structure (graphiclineweb.wordpress.com)
- Daily Tip: How to Add .html to the End of a WordPress URL (pressography.com)
- Remains of the Day: Many WordPress Sites Redirecting to Malware [For What It’s Worth] (lifehacker.com)
- Typo in an inbound link? Redirection to the rescue! (robcottingham.ca)
- IIRF causes a loop with wordpress pretty permalinks (stackoverflow.com)