Êtegory% in Permalink – Actually Possible?
-
1. This doesn’t work in Apache <2.0. I’ve convinced myself of that by playing around with it the RewriteRules a whole heck of a lot.
First question:
Anyone know of good hosts that run Apache 2.0? All the ones that I’ve seen seem to run Apache 1.3.33. I’m pestering my host to upgrade, but we’ll see how that goes.2. I’ve worked out a kinda/sorta workaround hack that allows you to have category links like
/category/%category%and permalinks like/%category%/%postname%. Basically, I just took the regexes created by WP for mod_rewrite, and ported them into a php script that parses the request URI usingpreg_replace. If nothing matches, then it sets the$_SERVER['PATH_INFO']var, and hopes for the best. It seems to be working.However, I’d really like to release this as a plugin, but I’m a total WP noob. In order to make it a plugin, I’m sure that you’d want to be able to have the script do things in a more generalized way, perhaps using some of the same logic that generates the .htaccess rules. Then, the permalink management page could perhaps:
- Sniff for Apache version. If >= 2, do what you’re doing now.
- If < 2, then write a simpler .htaccess file, like so:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp/
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [S=39]
RewriteRule ^(.*)$ /wp/uricruncher.php
</IfModule>
Then, write the “actual” rules touricruncher.php. (Or, perhaps that file could contain a function that does what I’m doing in a more generalized way, based on the permalink settings.)
If any WP gurus want to give me a few pointers to get started making that happen, I think we may end up with a plugin to reliably make %category% permalinks work in Apache 1.3.
Second Question:
Does anyone know the relative server strain with using mod_rewrite vs. preg_replace? I wonder if this method will drag things down or strain the server too much by calling preg_replace about 40 times in a row.Third Question:
Let’s say that you have a post inchild-category, which is a child ofparent-category. You also have a “page” that is a child of a parent page.I’m wondering how it can tell the difference between
/parent-category/child-category/post-name
and
/this-is-a-page/this-is-a-child-pageI can’t seem to figure out how to handle this in the preg_replace rules that are chomping the URI. If I rewrite the second one to
index.php/this-is-a-page/this-is-a-child-page, it works fine, but if I rewrite the first one toindex.php/parent-category/child-category/post-name, then I get the 404 page. But how can the script tell the difference between the two, since they match exactly the same regex?
Any ideas?
The topic ‘Êtegory% in Permalink – Actually Possible?’ is closed to new replies.