I would like demands to my website to operate the following:

http://example.com/ would pull-up the index.php file (the present default behavior) ideally without exhibiting the index.php

http://example.com/foo.php would pull-up foo.php as could be expected

http://example.com/blerg would redirect to http://example.com/bar.php?code=blerg

I've the next rewrite rules at this time

    RewriteRule ^/(.*\.(php|html|htm|css|jpg))$ /$1 [NC,L]
    RewriteRule ^/(.*)$ /bar.php?code=$1 [NC,L]

which almost works, except http://example.com/ pulls up bar.php rather than index.php

Ideally I wouldn't need to have every possible file extension within the first rule, I'd rather it simply identify whether it's a real file.

Not quite what you've requested I understand, however i frequently make use of this inshtaccess:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php

..to transmit something that is not a real file or directory to index.php, which in turn consists of logic to interpret whatever's within the URL string.

e.g.

$url_array = split('/', $_SERVER['REQUEST_URI']);
array_shift($url_array); // remove first value as it's empty

Found an answer that actually works

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/([^.]+)$ /bar.php?code=$1 [QSA,L]

http://example.com/ directs to index.php correctly (without showing index.php)

http://example.com/abc directs to close.perl?signalEqualsmastening numbers

http://example.com/foo.php works normally.

Presuming this really is inshtaccess and never the apache conf file, there is no / in front of part one of the rewrite rule. So if you wish to map:

http://example.com/blah.digital

you need to do:

RewriteRule ^blah\.jpg$ /some_other_file.jpg [L]

Note the possible lack of a number one / and also the getting away from the period (.) otherwise it matches any character (eg without them, the rule would match blahxjpg).

And if you are redirecting something that's otherwise a directory, you might find the customer or even the server puts a trailing slash. To cope with it I typically simply do this::

RewriteRule ^directory/?$ /some_other_directory/index.php [L]

or similar.

That last point pertains to:

RewriteRule ^/(.*)$ /bar.php?code=$1 [NC,L]

Essentially change it out to:

RewriteRule ^/?(.*)$ /bar.php?code=$1 [NC,L]

and i believe it'll get it sorted out.

Make use of a RewriteCond directive while watching second rule to ensure that it only matches the Web addresses you would like, e.g.:

RewriteCond %{REQUEST_URI} ^/blerg$
RewriteRule ...

Give a rule that intercepts the http://example.com/ request and prevents the final rule from running:

RewriteRule ^/(.*\.(php|html|htm|css|jpg))$ /$1 [NC,L]
RewriteRule ^/$ /index.php [L]
RewriteRule ^/(.*)$ /bar.php?code=$1 [NC,L]

I generally add QSA ("query string append") to my rules, too: [QSA,L].

This rule set forces demands to non-existent files to undergo a handler script:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /handler.php?request=$1 [QSA,L]