Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

WordPress auto corrects the permalinks(URLs) even if it is entered incorrectly. For e.g. WordPress will land you in example.com/some-post even if you enter example.com/idontexist/some-post or even example.com/some

It could be that, WordPress uses RegEx like or some matching algorithm that compares from right to left and if it finds a match, it will take you to the page even if there are /.*/ left on the left. Just a guess! How does WordPress do this?

Edit: I also noticed that the .htaccess file checks for virtual file/directories using !f and !d and redirects the request to index.php on the blog folder.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

The redirect_canonical function in /wp-includes/canonical.php is called on any given URL and will attempt to best-guess the URL the user wanted, and redirect them to there, when a URL does not exist. It has a whole huge amount of code to do this for all sorts of common errors.

share|improve this answer
1  
Upvoted for "whole huge amount" :D. –  tnorthcutt Jun 8 '11 at 18:25

Use @JanFabry "Rewrite Analyzer" Plugin, over here in the "official" WPSE Plugin repository

share|improve this answer
1  
Thanks for the link –  Lobo Jun 9 '11 at 3:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.