[FONT=Courier New]# If the requested URL isn’t a real file
RewriteCond %{REQUEST_FILENAME} !-f
Then rewrite to add a .php extension
RewriteRule (.*) $1.php[/FONT]
Off the top of my head, I’m not sure how you would do this one, and frankly, I don’t think you should try. Google actually recommends against this kind of URL format. Since /search/s/abc/d/11/v/hello is the same as /search/d/11/v/hello/s/abc, which is the same as /search/v/hello/s/abc/d/11, you’re going to end up with an unnecessarily high number of URLs that point to identical content.
While I would modify Jeff’s code to require only lowercase characters, that would have to be dependent upon your file names and whether you want to allow this for subdirectory requests. IMHO, it’s better to have mod_rewrite do a little error checking for you so I would also check to see whether the file exists WITH the .php extension before redirecting:
RewriteEngine on
# Check whether file exists
RewriteCond %{REQUEST_FILENAME} !-f
# Check whether request is a directory
RewriteCond %{REQUEST_FILENAME} !-d
# CHECK WHETHER file exists with .php extension
RewriteCond %{REQUEST_FILENAME}\\.php !-f
RewriteRule ^([a-z]+)$ $1.php [L]
One advantage of this is that the greedy problem disappears when you to do work on your second “problem.”
# Convert three key/value pairs in URI to query string
# Change character range definitions to include digits or CAPS if required (it is in your example)
RewriteRule ^([a-z]+)/([a-z]+)/([a-z]+)/([a-z]+)/([a-z]+)/([a-z]+)/([a-z]+)$ $1.php?$2=$3=$5&$6=$7 [L]
Note that, to match d’s value of 11, you WILL have to change the value’s character range definition (at least once) to [a-z0-9]+ or simply [0-9]+, however, using character range definitions will help you get rid of garbage.
IF your key value pairs will ALWAYS be search, d and v IN THAT ORDER, then I would remove those character range definitions and replace with those values.
Alternatively, you could generate the problem Jeff mentioned (different URIs for same content) by simply listing the acceptable key names like (search|d|v). Not enough information to give a recommendation, though.
This is why. Note that when dklynn recommended matching only letters, he also said it depends on whether you want to allow for subdirectory requests. And it seems you do want to allow for subdirectory requests.
I’d recommend you change the pattern to FONT=Courier New[/FONT]. This pattern is standard practice, and it’s used even in the Apache documentation for exactly this kind of purpose.