Tag Archive: Permalink Structure

WordPress Permalinks Generated But Not Redirected

Introduction

Appalled

Appalled

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….

SP Permalink Settings

SP Permalink Settings

When one installs WordPress for the first time, permalinks are set to the default – so this current post would be:

 http://strangelyperfect.tv/?p=11622

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:

http://strangelyperfect.tv/11622/wordpress-permalinks-generated-but-not-redirected

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:

/%post_id%/%postname%/

Now, on firing up a post, say this one,

http://strangelyperfect.tv/11428/victory-or-is-it-victory-jesse-willms-surrenders-all-to-ftc-onslaught/ ,

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.

A real key to resolving my problem was here, Custom Permalinks Generated But Not Redirected in the WordPress forums.  Specifically, it comes from the user, James, a Happiness Engineer!

He suggested adding index.php between the domain name and permalink structure.  So my custom structure changed to:

index.php/%post_id%/%postname%/

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:

http://strangelyperfect.tv/11428/victory-or-is-it-victory-jesse-willms-surrenders-all-to-ftc-onslaught/

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!

Conclusion

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

My permalinks in 2015

My permalinks in 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!

NoIdeaDeer


 

Enhanced by Zemanta

Related Posts:

Permalink Structure Change

This site has had a bit of a jiggle in the background recently and the most recent thing I’ve done is to adjust the permalink structure to /%post_id%/%postname%/.

I’ve done this as

  • I like to put posts into several categories – which would give multiple SEO entries – which is bad.. (don’t tell me to use one category – it’s how my brain works! ;-)
  • I want a unique post entry so that there is no possible chance of post confusion
  • I don’t need the date parts suggested in most blogs as the calendar thing should still work…
  • I want the shortest, most descriptive and UNIQUE post entry/title/thingy

To make sure I haven’t got link rot (as I found here), I’ve used a plugin rather than twiddling with .htaccess. This is Dean’s Permalinks Migration Plugin Version 1.0. However, it’s got a bug apparently so the fix is here in this Weblog Tools Collection post, or download here from g30rg3 Blog or from WordPress here.

This has started as since installing Alex King’s 404 Notifier I’ve noticed a few oddities shooting back to me. One type of thing is this which I take as the RSS option:

404 URL:

Referring URL:

User Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6

It’s some sort of search I guess. Doing a whois on eclub.lv and a google search on various parts of the string shows lots of weirdness on the web that I still haven’t cracked. The main things are that

  • I never wrote a page like anything there,
  • I’ve chopped down my translation widgets
  • the “chives” bit is archive truncated which is why I’ve changed the permalinks to see what happens
  • I’ve got folders like “de” blocked in the robots.txt file so they shouldn’t be searched by legitimate robot engines. It’s normally is added to the post address when the translation engine plugin is installed.
  • I’ve tried a few translators. They all have the extra folder effect.

Watch this space, I guess.

Related Posts:

WordPress User Registration Spam

I’ve had quite a few search enquiries and hits for komatoz.net on my sites recently so there are obviously a lot of people suffering out there with spamming and registration problems that I’ve “currently” ;-) got under control. (We all know that this is a continuous battle against spammers as their approaches and techniques change though!).

This post is really a revisit and clarification of an earlier one here and shows some of the things I do to keep the spammy bastards at bay as there is no “one fix for everything” solution.

You could call them my Top Three!

Use of SABRE

What I’ve found, when using the excellent Sabre WordPress plugin, is that there are a heap of “usual suspects” that circle round and round a few IP addresses. Usually I’ll get supposedly real e-mail addresses from places like:

komatoz.net
gawab.com
yandex.ru
mail.ru
inbox.ru

…and previously I had them locked out by name – but that doesn’t work as they’re spoofed.
Sabre is useful as it allows you to spot repeat hits from certain IP addresses after they’ve been blocked by the use of an .htaccess file.

Use of the .htaccess File

I’ve also made use of the .htaccess file in the website roots to block these names and a wodge of IP addresses. It’s become obvious that the differences between the SABRE logs of each website were due to differences between the .htaccess settings (I’d missed off a couple of IP’s between files) so now the blocked list is as follows:

#BEGIN_ADDS
Options -Indexes

order allow,deny

deny from 24.1.39.117
deny from 38.99.101.151
deny from 58.65.237.113
deny from 58.65.239.146
deny from 61.152.95.162
deny from 64.233.179.101
deny from 64.86.69.6
deny from 64.94.4.196

deny from 66.235.180.189
deny from 72.249.100.188
deny from 75.126.3.177
deny from 78.110.160.130
deny from 85.225.117.179
deny from 87.118.112.50
deny from 88.255.69.10
deny from 89.149.227.193
deny from 89.149.241.229
deny from 89.207.216.211

deny from 160.114.38.82
deny from 190.2.0.2
deny from 192.116.79.226

deny from 195.2.114.31
deny from 195.2.114.32
deny from 195.245.119.76
deny from 195.225.178.15

deny from 203.162.2.137
deny from 205.158.160.76
deny from 208.187.80.135

deny from 210.14.128.112
deny from 210.14.128.172
deny from 210.22.158.132
deny from 212.175.13.169

deny from 216.240.152.9
deny from 217.20.115.118
deny from 218.61.16.8

allow from all

#END_ADDS

This has been applied to all my sites so there should be some consistency between the residual IP addresses getting past the file.

If you don’t know how to do this, ask me or look it up on the net like I did. I’ve also left some links at the bottom. If you are using WordPress, they advise you to set one up to manage the permalink structure. All you need to do is open .htaccess and paste the list after the WordPress additions. The # hash is a line comment (remming it out).

The .htaccess file is an immensely powerful tool. It’s a huge Apache thing. What I’m doing above is to block the need for an “index” file which stops unwanted folder trawling if a folder doesn’t have an index file; and then I block any enquiries from the list of IP addresses. This is empirically derived so if you know people with Russian email addresses you’ll have to modify the list, which is set up for my blockings only!

The Apache server always does three swipes through the file hence the specific terms:
order allow,deny

First it allows all sites and second it denies any IP’s on the list. The third sweep does nothing in this file.

The use of .htaccess in this way takes the load away from WordPress so that it never even gets to do any filtering!
I also use .htaccess to allow only pictures (say) into an images folder and block active script files explicitly. So it’s a file type filter as well… As I said, it’s very powerful.

Make sure that you block write access to the file afterwards! Same goes for your robots.txt file and various folders….

Use of Akismet

As well as this lot, I also use Akismet, which most folk use anyway as it’s part of the default WordPress install. Anything that consistely gets through can be added to the .htaccess file along with the odd spurious SABRE detections.
I do a few more things as well, mostly for normal comments and trackbacks, but in truth, the three-pronged approach I’ve detailed here traps most bad guys.

I started all this when I was hacked (or more correctly cracked – I hate the way the usage has been hi-jacked on this..) by some Turkish activists. I learnt the hard way! :-( See my earlier post here.

.htaccess usage links

Comprehensive guide to .htaccess

.htaccess

Apache HTTP Server Version 1.3

Hope this helps someone! Let me know if it has.

Related Posts:

© 2007-2017 Strangely Perfect All Rights Reserved -- Copyright notice by me