[Apache] <location> definitie in .htaccess

Pagina: 1
Acties:

  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06-2025

drm

f0pc0dert

Topicstarter
Er staat in de php-manual een leuk geintje:
het forceren van requests op een bepaalde directory te verplichten langs een bepaalde parser oid te gaan:
code:
1
2
3
<Location /source>
    ForceType application/x-httpd-php
</Location>

om dan vervolgens in je webroot een bestand "source" te zetten, waar dus php code in staat die e.e.a. aan source genereert. Dan zou een request als deze dus ipv. gegenereerde html de php source moeten laten zien:

http://www.host.com/source/pages/bladibla.php

waar het script dus zelf in

http://www.host.com/pages/bladibla.php

staat.

Maar, nu wil ik dit alleen in 1 bepaalde directory laten werken. Moet die <location> dan in een htaccess, en zo ja, hoe? Want ik ging hem gewoon zo in een .htaccess zetten en toen zei apache:
[Thu Aug 30 16:01:12 2001] [alert] /usr/local/etc/httpd/htdocs/cm/.htaccess: <Location not allowed here
Ik ben dan ook een behoorlijke newB op het terrein van dit soort Tweaks.

source .htaccess
code:
1
2
3
<Location ./source>
    ForceType application/x-httpd-php
</Location>

source bestand "source" (uit php manual)
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?
?>
<html>
<body>
<?
    $script = getenv ("PATH_TRANSLATED");
    if(!$script) {
        echo "<BR><B>ERROR: Script Name needed</B><BR>";
    } else {
        if (ereg("(\.php|\.inc)$",$script)) {
            echo "<H1>Source of: $PATH_INFO</H1>\n<HR>\n";
            highlight_file($script);
        } else {
            echo "<H1>ERROR: Only PHP or include script names are allowed</H1>"; 
        }
    }
    echo "<HR>Processed: ".date("Y/M/d H:i:s",time());
?>
</body>
</html>
<?
?>

Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz