git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv3] gitweb: make static files accessible with PATH_INFO

From
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Date
Jan 27, 2009, 13:29 UTC
Message-ID
<1233062946-22395-1-git-send-email-giuseppe.bilotta@gmail.com>

When PATH_INFO is defined, static files such as the defalt CSS or the shortcut icon are not accessible beyond the summary page (e.g. in shortlog or commit view).

Fix this by adding a <base> tag pointing to the script base URL.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
Of course, last time I forgot that the BASE href is supposed to be
absolute. While Opera apparently has no problem with it being relative,
other browsers such as Firefox are stricter about it.
 gitweb/gitweb.perl |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 931db4f..411b1f6 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2901,6 +2901,14 @@ sub git_header_html {
 <meta name="robots" content="index, nofollow"/>
 <title>$title</title>
 EOF
+# the stylesheet, favicon etc urls won't work correctly with path_info unless we set the appropriate base URL
+	if ($ENV{'PATH_INFO'}) {
+		my $base = $my_url;
+		my $sname = $ENV{'SCRIPT_NAME'};
+		$base =~ s,\Q$sname\E$,,;
+		$base .= "/";
+		print "<base href=\"$base\"/>\n";
+	}
 # print out each stylesheet that exist
 	if (defined $stylesheet) {
 #provides backwards capability for those people who define style sheet in a config file
-- 
1.5.6.5
Next: Jakub Narebski
Message 1 of 5 in “[PATCHv3] gitweb: make static files accessible with PATH_INFO”
  1. Giuseppe BilottaJan 27, 2009
  2. Jakub NarebskiJan 28, 2009
  3. Giuseppe BilottaJan 28, 2009
  4. Jakub NarebskiJan 28, 2009
  5. Jakub NarebskiJan 28, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.