I have thought about using WordPress – or maybe just copy a few functions to an internal site – but before I’d use it I would like to know how it’s working.
How is the .htaccess and URL rewrite combined with index.php?
- The .htaccess sends everything to index.php and I have tried to follow every file but I can’t see how index.php detects the url.
How could I build a simple version of that?
There is a very detailed summary in the WordPress Codex on Using Permalinks.
If you are interested in how it was implemented, see the WordPress Rewrite API in file
/wordpress/wp-includes/rewrite.php
and check the related reference entry in WP Codex.index.php really gets called with parameters:
i’m guessing you’re looking for a way to have nice links for seo without the ? parameters
the htaccess part could look like this:
2.+3. the link doesnt point to a real file or dir
so eg “www.homepage.com/superpage” gets mapped to “www.homepage.com/index.php?page=superpage”
Correction… according to the .htaccess rules by default in WordPress and the ones listed below, it will first look if there is a file or a directory that exists in the path given in the URL. If there is no file/directory present at that location, index.php is called.
This ensures that the admin section works the way it does. This also ensures that you can dump any file in the WordPress directory and still be able to access them.
Once the redirection reaches index.php, the WordPress Redirection API is called as indicated by this post.