English 中文(简体)
Wordpress stop post redirects
原标题:

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.

最佳回答

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

remove_filter( template_redirect ,  redirect_canonical );
问题回答

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





相关问题
Converting GET method url s to logical permanent links

I have a J2EE application with a web service which goes like http://servername/service?task=getFile&id=25 How can I convert these type of urls to http://servername/service/getFile/25 http://...

wordpress permalink post_type

i am looking for a way to get the post_type into a wordpress permalink structure - especially considering custom post_type s defined by my own plugin. is there an easy way to do that, or do you know ...

.htaccess gone for deleted, permalink database entries

I have event entries in a php application with a permalink structure for the events. I m creating a dynamic xml sitemap for google et al. which creates new url nodes as events are added, and when an ...

Wordpress stop post redirects

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

Recommended url structure for parent child list in mvc

If I am listing child items of a parent in an asp.net mvc app, is there a best practice to how the url structure should be formed? Example: 1. http://app/parent/<parentID>/children 2. http://...

Rails Friendly URLs

I have a model called Project and I ve defined the "to_param" method as this: def to_param permalink end I am using this permalink plugin github.com/febuiles/make_permalink so when I call p....

Permalink/slug best practices

I m about to setup permalinks on a website and I m wondering what sort of conventions I should follow in regards to generating them from the existing table of news articles. So far here are the rules/...

热门标签