Fossil SCM
Use the SCRIPT_NAME environment variable rather than REQUEST_URI to find the base name of the CGI script.
Commit
c23469468bc6a8a47bb33bb94e61dcaa5058d3d9
Parent
ec82a32b8010ec0…
1 file changed
+4
-15
+4
-15
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -427,25 +427,14 @@ | ||
| 427 | 427 | */ |
| 428 | 428 | void set_base_url(void){ |
| 429 | 429 | int i; |
| 430 | 430 | const char *zHost = PD("HTTP_HOST",""); |
| 431 | 431 | const char *zMode = PD("HTTPS","off"); |
| 432 | - const char *zCur = PD("REQUEST_URI","/"); | |
| 433 | - | |
| 434 | - for(i=0; zCur[i] && zCur[i]!='?' && zCur[i]!='#'; i++){} | |
| 435 | - if( g.zExtra ){ | |
| 436 | - /* Skip to start of extra stuff, then pass over any /'s that might | |
| 437 | - ** have separated the document root from the extra stuff. This | |
| 438 | - ** ensures that the redirection actually redirects the root, not | |
| 439 | - ** something deep down at the bottom of a URL. | |
| 440 | - */ | |
| 441 | - i -= strlen(g.zExtra); | |
| 442 | - while( i>0 && zCur[i-1]=='/' ){ i--; } | |
| 443 | - } | |
| 444 | - while( i>0 && zCur[i-1]!='/' ){ i--; } | |
| 445 | - while( i>0 && zCur[i-1]=='/' ){ i--; } | |
| 446 | - | |
| 432 | + const char *zCur = PD("SCRIPT_NAME","/"); | |
| 433 | + | |
| 434 | + i = strlen(zCur); | |
| 435 | + while( i>0 && zCur[i-1]=='/' ) i--; | |
| 447 | 436 | if( strcmp(zMode,"on")==0 ){ |
| 448 | 437 | g.zBaseURL = mprintf("https://%s%.*s", zHost, i, zCur); |
| 449 | 438 | g.zTop = &g.zBaseURL[8+strlen(zHost)]; |
| 450 | 439 | }else{ |
| 451 | 440 | g.zBaseURL = mprintf("http://%s%.*s", zHost, i, zCur); |
| 452 | 441 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -427,25 +427,14 @@ | |
| 427 | */ |
| 428 | void set_base_url(void){ |
| 429 | int i; |
| 430 | const char *zHost = PD("HTTP_HOST",""); |
| 431 | const char *zMode = PD("HTTPS","off"); |
| 432 | const char *zCur = PD("REQUEST_URI","/"); |
| 433 | |
| 434 | for(i=0; zCur[i] && zCur[i]!='?' && zCur[i]!='#'; i++){} |
| 435 | if( g.zExtra ){ |
| 436 | /* Skip to start of extra stuff, then pass over any /'s that might |
| 437 | ** have separated the document root from the extra stuff. This |
| 438 | ** ensures that the redirection actually redirects the root, not |
| 439 | ** something deep down at the bottom of a URL. |
| 440 | */ |
| 441 | i -= strlen(g.zExtra); |
| 442 | while( i>0 && zCur[i-1]=='/' ){ i--; } |
| 443 | } |
| 444 | while( i>0 && zCur[i-1]!='/' ){ i--; } |
| 445 | while( i>0 && zCur[i-1]=='/' ){ i--; } |
| 446 | |
| 447 | if( strcmp(zMode,"on")==0 ){ |
| 448 | g.zBaseURL = mprintf("https://%s%.*s", zHost, i, zCur); |
| 449 | g.zTop = &g.zBaseURL[8+strlen(zHost)]; |
| 450 | }else{ |
| 451 | g.zBaseURL = mprintf("http://%s%.*s", zHost, i, zCur); |
| 452 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -427,25 +427,14 @@ | |
| 427 | */ |
| 428 | void set_base_url(void){ |
| 429 | int i; |
| 430 | const char *zHost = PD("HTTP_HOST",""); |
| 431 | const char *zMode = PD("HTTPS","off"); |
| 432 | const char *zCur = PD("SCRIPT_NAME","/"); |
| 433 | |
| 434 | i = strlen(zCur); |
| 435 | while( i>0 && zCur[i-1]=='/' ) i--; |
| 436 | if( strcmp(zMode,"on")==0 ){ |
| 437 | g.zBaseURL = mprintf("https://%s%.*s", zHost, i, zCur); |
| 438 | g.zTop = &g.zBaseURL[8+strlen(zHost)]; |
| 439 | }else{ |
| 440 | g.zBaseURL = mprintf("http://%s%.*s", zHost, i, zCur); |
| 441 |