I'm replacing index.cgi of gitweb with a static index.html page.
However I don't want links to gitweb repositories to break, such as http://example.com/?p=foobar;
My non-working .htaccess currently looks like:
DirectoryIndex index.html index.php
RewriteCond %{QUERY_STRING} p
RewriteRule ^/ /index.cgi
What am I missing?
By my reading of the RewriteRule docs ("What is matched?" box), if your RewriteRule is in a Directory section or .htaccess file, then the leading
/
will be stripped away, so the pattern in your rule won't match. You could try replacing the pattern by just^
, i.e.With that rule you will never be able to access the index.html page as the redirect will match anything.
You would need to do something along the lines of
Which should work out similar to 'if you don't have a querystring go to index.html, otherwise go to index.cgi and pass the rest of the string along too!'
It will match any URI that is not index.cgi or index.html beginning with a p query string and rewrite it to your cgi.
The L option means that Apache stops processing rewrite rules.