RewriteCond %{REQUEST_URI} !\.(jpe?g|png|gif|css|js) # rewrite if the given string is not an already existing file RewriteCond %{REQUEST_FILENAME} !-f # rewrite if the given string is not an existing directory RewriteCond %{REQUEST_FILENAME} !-d # rewrite to Lanas.pl with QUERYSTRING appended RewriteRule (.*)(/(.*))? /cgi-bin/Lanas.pl?$1=$3 RewriteRule ^/?$ /cgi-bin/Lanas.pl