I have numerous index.php scripts using SEO-friendly arg format like
example.com/path/to/index.php/opt/arg
and would like to rewrite or force a handler to have
example.com/path/to/ih/opt/arg
and thus shorten the index.php part. [Well, I'd like to get rid of it entirely, but don't want to go back to
example.com/path/to/?opt&arg
format.] This should be generally supported in any dir on the site rather than requiring .htaccess, alias, or http.conf modification. For my next trick I'll expand 'ih' for PHP to also cover 'ip' for Perl, 'ir' for Ruby, 'iy' for Python, and perhaps others. [My original thought was just 'i' but then I realized that there are other languages for which I'll want this as well.]
I've tried playing with MultiViews but clearly don't know what I'm doing :-) I've looked extensively at mod_rewrite but just can't see how to implement something like this. I took a quick look at forcing a handler but 1) am not sure that's really what I mean (and so I beg forgiveness in advance for perhaps using the wrong term) and 2) have the added fun challenge of running 1.3 where I host vs 2.2 at home :-)
Suggestions?
TIA & HAND
David T-G http://justpickone.org/davidtg/email/
Since you looked into using mod_rewrite, I'm going to assume you don't mind making a one-time change to .htaccess
or httpd.conf
, but just don't want to have to do it for every index.php on your site. (Correct me if I'm wrong!)
Try this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*\/)?ih(\/.*)?$ $1index.php$2 [L,QSA]
You may not need the two RewriteCond
s. They just check that the original URL did not exist as an actual file on the system, before rewriting that URL.