mod_rewrite question
Smylers
Smylers at stripey.com
Mon Jan 14 00:40:00 GMT 2008
David Cantrell writes:
> mod_rewrite is, as is its wont, annoying me again. More specifically,
> its shitty documentation is annoying me. Because despite careful study,
> I can't figure out how to persuade it that both
>
> /foo
> /?.=foo
>
> should map to
>
> /index.pl?.=foo
First, if a request doesn't have a query string then grab the path and
set that as the . parameter in the query string:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/(.*) /?.=$1
Then if a request doesn't have a path, use index.pl:
RewriteRule ^/$ /index.pl
I haven't tried out the above. If it doesn't work then please post back
here, preferably with your Apache version and some RewriteLog output,
and I'll try to work out what I got wrong.
Note that the above will cause havoc if you have anything else (images,
CSS, whatever) being served from this URL; that can be fixed by
restricting what the (.*) matches.
Also have you tried DirectoryIndex for specifying index.pl? If that
works it reduces the amount of mod_rewrite you need.
Good luck!
Smylers
More information about the london.pm
mailing list