Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

htaccess Zugriff per PHP

Empfohlene Antworten

Veröffentlicht

Hi,

ich möchte gerne per PHP Script eine URL aufrufen, die per htaccess geschützt ist.

welche Header muss ich mitsenden, damit er benutzername und passwort sendet und ich zugriff bekomme?

Danke!

lg KuMpEl2

bei basic auth (siehe RFC 2617 punkt 2):

'Authorization: Basic ' . base64_encode($deinusername . ':' . $deinpasswort

bei digest auth (siehe RFC 2617 punkt 3):

'Authorization: Digest username=\"$deinusername \", direktive, direktive, direktive, ...

ein direktes fopen nach http://deinusername:deinpasswort@deinhostname.deinedomain.tld/bla/foo.php

sollte auch funktionieren.

s'Amstel

Es will einfach nicht...

Authorization Required

This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.


<?php
$server = 'host.com';
$request = 'GET /pfad/zum/script';
$tt = "
GET /nic/denic_stats.cgi HTTP/1.0\n
Accept: text/html, text/*; q=0.9\n
User-Agent: Mozilla/4.0 (compatible; MSIE 6; Windows NT 6.0)\n
Connection: Keep-Alive\n";
$tt1 = "
GET /nic/denic_stats.cgi HTTP/1.0\n
Accept: text/html, text/*; q=0.9\n
User-Agent: Mozilla/4.0 (compatible; MSIE 6; Windows NT 6.0)\n
Connection: Keep-Alive\n
Basic Authorization: Basic (korrekter code)";
$test = fsockopen($server,80);
fputs($test,$tt);
fputs($test,$tt1);
fputs($test,$request);
$result = '';
while(!feof($test))
{
$result .= fgets($test);
}
fclose($test);
echo $result;
?>
[/PHP]

Wenn ich mit HTTP/1.1 arbeite gibt er mir folgendes aus:

Bad Request

Your browser sent a request that this server could not understand.

client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /pfad/zum/script.cgi

Ich verzweifel bald... :(

Ich verzweifel bald... :(
Dann sieh doch einfach mal die Fehlermeldung an, die du bekommen hast!

Die ist nicht nur da um belächelt zu werden sondern enthält in diesem Fall auch genau den Hinweis, den du brauchst: request without hostname.

HTTP/1.1 request without hostname (see RFC2616 section 14.23):
Und was steht in section 14.23?

The Host request-header field specifies the Internet host and port

number of the resource being requested, as obtained from the original

URI given by the user or referring resource (generally an HTTP URL,

as described in section 3.2.2). The Host field value MUST represent

the naming authority of the origin server or gateway given by the

original URL. This allows the origin server or gateway to

differentiate between internally-ambiguous URLs, such as the root "/"

URL of a server for multiple host names on a single IP address.

Host = "Host" ":" host [ ":" port ] ; Section 3.2.2

A "host" without any trailing port information implies the default

port for the service requested (e.g., "80" for an HTTP URL). For

example, a request on the origin server for

<http://www.w3.org/pub/WWW/> would properly include:

GET /pub/WWW/ HTTP/1.1

Host: www.w3.org

[...]

Also Host-Header mitsenden!

Hi,

hab jetzt auch Host mitgesendet, aber trotzdem gleicher fehler....

:(

Es will einfach nicht...


<?php
$server = 'host.com';
$request = 'GET /pfad/zum/script';
$tt = "
GET /nic/denic_stats.cgi HTTP/1.0\n
Accept: text/html, text/*; q=0.9\n
User-Agent: Mozilla/4.0 (compatible; MSIE 6; Windows NT 6.0)\n
Connection: Keep-Alive\n";
$tt1 = "
GET /nic/denic_stats.cgi HTTP/1.0\n
Accept: text/html, text/*; q=0.9\n
User-Agent: Mozilla/4.0 (compatible; MSIE 6; Windows NT 6.0)\n
Connection: Keep-Alive\n
Basic Authorization: Basic (korrekter code)";
[/PHP]

HTTP 1.0 kennt m.w. keinen Host-header, nimm HTTP 1.1 und schick einen mit: "Host: www.denic.de"

wo ist dieser im obigen aufruf?

was ist "Basic Authorization: Basic"? das ist kein gültiger HTTP-header.

s'Amstel

Nach echt vielen versuchen, nun klappt es endlich.

Wer aufklärung möchte, kann mich gerne einmal anschreiben.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.