pete,
The best way is NOT to use the id of the content items but the title or name field in your db (you DID read my tutorial Article, didn't you?). All that requires is that your title/name field be unique (MySQL can take care of that by preventing duplicates). If you don't believe me, the record article titles at wilderness-wally.com ARE the titles, not the record ids and nearly all links ARE the titles. Of course, I HAD to convert the title to something which did not show %20 for spaces, etc, and convert back before accessing the db but the effect is EXACTLY that my client wanted - and what you say that you want, too.
As requested:
Code:
Options +FollowSymlinks
# + is not used
RewriteEngine on
RewriteBase /
# RewriteBase is only used to UNDO a mod_alias Redirect - none here!
#Catch specific reference to a klvc - how can I
RewriteRule ^klvc/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ klvc_store.php?klvc=$1&mantext_id=$2 [NC]
# Example URIs, if you please!
# Your atoms appear to contain all the usable characters
# rather than the subset which you are after
# Same below
#Catch specific reference to a news article
RewriteRule ^klvc/([a-zA-Z0-9_-]+)/news/([0-9_-]+)$ klvc_news.php?news_id=$1 [L,R=301]
#Catch specific reference to a booking form
RewriteRule ^klvc/([a-zA-Z0-9_-]+)booking/(.*)$ klvc_booking.php/$1 [L,R=301]
#Catch specific reference to a contact form
RewriteRule ^klvc/([a-zA-Z0-9_-]+)contact/(.*)$ klvc_contact.php/$1 [L,R=301]
RewriteRule ^klvc/([a-zA-Z0-9_-]+)$ klvc_store.php?klvc=$1 [NC]
#Catch anything left
#How do catch anything that hasn't matched and redirect to parent site?
# redirect all remaining traffic to /klvc
# How about
RewriteRule ^klvc/ klvc_lost.php [L]
As I started, though, this is NOT the way to do what you're after. I'd probably start with the links, i.e., klvc/ is not recommended as it's "useless" in the context of your regex. I'd start those (above) links with news/, booking/, contact/ or store/ (the redirection can remain to the klvc_yadda-yadda) which MAY allow you to combine your mod_rewrite statements.
From there, I'd have to see some examples of your URIs to give the EXACT regex (for the characters you DO want to accept) AND the ... duh, WHY are you using MultiViews (klvc_contact.php/$1 rather than klvc_news.php?news_id=$1)? Using MultiViews can cause a LOT of problems (relative links) while you should be able to use something like klvc_$1.php?$1_title=$2 if you constructed your db using common field names differentiated by the news_/booking_/contact_/store_.
I guess the lesson here is PPPPPPP (proper prior planning prevents piss poor performance) ... and other problems!
Regards,
DK
Bookmarks