First, you can't match against URL fragments (the #dir
part) because that doesn't ever get sent to the server. It's a client side only thing.
Second, you can't match against the query string (the ?show=dir
part) in the %{REQUEST_URI}
variable, you need to use %{QUERY_STRING}
instead.
So try:
RewriteEngine On
RewriteCond %{QUERY_STRING} !^show=dir$
RewriteRule ^$ http://example.com/ [nc]