views:

71

answers:

2

I'm having a Wordpress problem regarding permalinks.

When I have a post whose permalink is say, /2009/10/podcasts, trying to access /podcasts redirects to /2009/10/podcasts. Is there any way to stop this behavior so I can handle it as a 404?

I'm using a custom 404 handler that checks if the request is a 404 error and executes a Kohana request from within Wordpress.

A: 

just checked with a default installation of wordpress - and indeed it seems to be a default behaviour of wordpress to look for the path anyways - no matter what directories you add hide. So also replacing the "/2010/01/some-long-url" by "/error/some-long-url" will redirect the reuest to "/2010/01/some-long-url".

Anyways - I can still suggest two workarounds: 1) if you really want to get a real 404 error you can use the redirect method in your htaccess to forward the request to a non-existing url - just add the one redirect-line like this:

Redirect /podcasts /podcasts-error

all together the htacces could then look like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Redirect /podcasts /podcasts-error
</IfModule>

2) If you don't really need the 404 error you may also just add a page and give it the exact same url - in this case it would be "podcasts". That would de-activate the forwarding. You could then add your own custom 'error message' to that page..

Greetz, t..

tillinberlin
+2  A: 

I just got the answer on the WP forums. It's

remove_filter('template_redirect', 'redirect_canonical');
Zahymaka