Forum Moderators: phranque
This is how it works right now:
http://www.myblog.com/mybooks/?book=catch-22
Which loads my custom theme template and displays the data corresponding to the book parameter - all based on PHP script I have in that template.
What I would like, however, is to rewrite a "friendly" url like this:
http://www.myblog.com/mybooks/book/catch-22
How would I add the rule I need to the existing Wordpress RewriteRule?
This is the default Wordpress rule:
RewriteEngine On
RewriteBase /myroot/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /myroot/index.php [L]
RewriteEngine On
RewriteRule ^book/([^/\.]+)/?$ index.php?book=$1 [L]
Any help is greatly appreciated.
Is the /mybooks URL-path within or below the /myroot path?
If the new rule is to work, it will need to go above the Wordpress rule, either in the same .htaccess file, in a .htaccess or config file above the Wordpress .htaccess file's directory, or in a path below root that is different from the path to the WP .htaccess file. In other words, the new rule must execute either first or exclusively.
If you get a 500-Server error, look at your server error log. It will often tell you what's wrong, and that information is useful to both you and to readers here.
Jim
Thank you very much for taking the time to respond. This has been a difficult nut to crack, but after a lot more searching a bit of good luck, I figured it out.
It turns out to have had nothing to do with modifying the rewrite rules in .htaccess after all. Instead, the solution was to the modify the query rules Wordpress uses internally to handle custom queries when sent as "friendly" URLs (or "Permalinks") by way of the $wp_rewrite function.
The answer that worked for me can be found in the Wordpress Codex document entitled "Custom Queries [codex.wordpress.org]," right at the bottom under the heading "Permalinks for Custom Archives." I just took the example in that article, added it to my plug-in script, and it worked.