PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > alt.apache.configuration > mod_rewrite & headers
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
alt.apache.configuration Apache web server configuration issues.

mod_rewrite & headers

Réponse
 
LinkBack Outils de la discussion
Vieux 15/02/2007, 13h39   #1
Dave
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut mod_rewrite & headers

If I use mod_rewrite to rewrite a requested url will it preserve the
headers of the requesting file?

e.g.

request www.mysite.com/audio/file1.mp3 - setting range offset within
header (range: bytes=1025700-)
rewrites to www.mysite.com/audio/process.php?p=file1.mp3

Ideally I want the process.php file to pickup the requesting file and
serve it up as partial content, which is why I need to get the
original header.

Is this possible using mod_rewrite?

Many thanks

Dave

  Réponse avec citation
Vieux 15/02/2007, 13h45   #2
Rik
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: mod_rewrite & headers

On Thu, 15 Feb 2007 14:39:31 +0100, Dave <spambox.dccobb@gmail.com> wrote:

> If I use mod_rewrite to rewrite a requested url will it preserve the
> headers of the requesting file?
>
> e.g.
>
> request www.mysite.com/audio/file1.mp3 - setting range offset within
> header (range: bytes=1025700-)
> rewrites to www.mysite.com/audio/process.php?p=file1.mp3


Headers & post values will be preserved on internal redirects, get
variables can be easily overwritten by accident if one's not carefull.
--
Rik Wasmus
  Réponse avec citation
Vieux 15/02/2007, 14h12   #3
Dave
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: mod_rewrite & headers


> Headers & post values will be preserved on internal redirects, get
> variables can be easily overwritten by accident if one's not carefull.
> --
> Rik Wasmus


Rik,

Sorry, I'm not sure what you mean by your last statement.

Cheers

Dave

  Réponse avec citation
Vieux 15/02/2007, 14h43   #4
Rik
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: mod_rewrite & headers

On Thu, 15 Feb 2007 15:12:12 +0100, Dave <spambox.dccobb@gmail.com> wrote:

>
>> Headers & post values will be preserved on internal redirects, get
>> variables can be easily overwritten by accident if one's not carefull..

>
> Sorry, I'm not sure what you mean by your last statement.
>


The part about the GET variables?
Most rewriting is done to get variables, for instance:
http://example.com/foo/bar
Is rewritten internally to:
http://example.com/index.php?foz=foo&baz=bar

That's a piece of cake, and usally works. Now what if we're trying this
URL:
http://example.com/foo/bar?foz=var

It's highly dependant on the actual rewrite and/or the receiving script
wether this script thinks the GET variable foz is 'var', 'foo', or maybe
both.

While POST & HEADER values can be altered, this most be done very
explicitly, so it's very hard to do it by accidant. Not so for the GET.
--
Rik Wasmus
  Réponse avec citation
Vieux 15/02/2007, 14h57   #5
Dave
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: mod_rewrite & headers


> The part about the GET variables?
> Most rewriting is done to get variables, for instance:
> http://example.com/foo/bar
> Is rewritten internally to:
> http://example.com/index.php?foz=foo&baz=bar
>
> That's a piece of cake, and usally works. Now what if we're trying this
> URL:
> http://example.com/foo/bar?foz=var
>
> It's highly dependant on the actual rewrite and/or the receiving script
> wether this script thinks the GET variable foz is 'var', 'foo', or maybe
> both.
>
> While POST & HEADER values can be altered, this most be done very
> explicitly, so it's very hard to do it by accidant. Not so for the GET.
> --
> Rik Wasmus


Rik,

With you. I won't need to request files with additional values passed
on the querystring. So the first example will apply. As long as I can
read the requesting header information, then I should be fine.

Many thanks

Dave


  Réponse avec citation
Vieux 15/02/2007, 22h45   #6
shimmyshack
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: mod_rewrite & headers

On 15 Feb, 14:57, "Dave" <spambox.dcc...@gmail.com> wrote:
> > The part about the GET variables?
> > Most rewriting is done to get variables, for instance:
> > http://example.com/foo/bar
> > Is rewritten internally to:
> > http://example.com/index.php?foz=foo&baz=bar

>
> > That's a piece of cake, and usally works. Now what if we're trying this
> > URL:
> > http://example.com/foo/bar?foz=var

>
> > It's highly dependant on the actual rewrite and/or the receiving script
> > wether this script thinks the GET variable foz is 'var', 'foo', or maybe
> > both.

>
> > While POST & HEADER values can be altered, this most be done very
> > explicitly, so it's very hard to do it by accidant. Not so for the GET.
> > --
> > Rik Wasmus

>
> Rik,
>
> With you. I won't need to request files with additional values passed
> on the querystring. So the first example will apply. As long as I can
> read the requesting header information, then I should be fine.
>
> Many thanks
>
> Dave


$_SERVER["HTTP_RANGE"] is what you need, and then you need to send
back a couple of headers to the application which plays the mpeg:
for instance here is the RR cycle for a raw mp3:
GET /readings/listen/esv/February15.mp3 HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:
1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
Accept: text/xml,application/xml,application/xhtml+xml,text/
html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Keep-Alive: 300
Range: bytes=417792-
If-Range: "228f8-3a43cd-708051a3"


HTTP/1.1 206 Partial Content
Date: Thu, 15 Feb 2007 22:33:25 GMT
Server: Microsoft-IIS/7.0
Last-Modified: Wed, 14 Feb 2007 00:01:07 GMT
ETag: "228f8-3a43cd-708051a3"
Accept-Ranges: bytes
Content-Length: 3400653
Vary: User-Agent
Content-Range: bytes 417792-3818444/3818445
Content-Type: audio/mpeg


the user-agent knew the Etag for the mp3, apache responds with this e-
tag as well as the Content-Range, and Accept-Ranges headers

make sure you generate the right headers with your php script and you
should be fine, and then of course read from the correct offset!!

  Réponse avec citation
Vieux 16/02/2007, 01h32   #7
shimmyshack
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: mod_rewrite & headers

On 15 Feb, 22:45, "shimmyshack" <matt.fa...@gmail.com> wrote:
> On 15 Feb, 14:57, "Dave" <spambox.dcc...@gmail.com> wrote:
>
>
>
> > > The part about the GET variables?
> > > Most rewriting is done to get variables, for instance:
> > > http://example.com/foo/bar
> > > Is rewritten internally to:
> > > http://example.com/index.php?foz=foo&baz=bar

>
> > > That's a piece of cake, and usally works. Now what if we're trying this
> > > URL:
> > > http://example.com/foo/bar?foz=var

>
> > > It's highly dependant on the actual rewrite and/or the receiving script
> > > wether this script thinks the GET variable foz is 'var', 'foo', or maybe
> > > both.

>
> > > While POST & HEADER values can be altered, this most be done very
> > > explicitly, so it's very hard to do it by accidant. Not so for the GET.
> > > --
> > > Rik Wasmus

>
> > Rik,

>
> > With you. I won't need to request files with additional values passed
> > on the querystring. So the first example will apply. As long as I can
> > read the requesting header information, then I should be fine.

>
> > Many thanks

>
> > Dave

>
> $_SERVER["HTTP_RANGE"] is what you need, and then you need to send
> back a couple of headers to the application which plays the mpeg:
> for instance here is the RR cycle for a raw mp3:
> GET /readings/listen/esv/February15.mp3 HTTP/1.1
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:
> 1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
> Accept: text/xml,application/xml,application/xhtml+xml,text/
> html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
> Keep-Alive: 300
> Range: bytes=417792-
> If-Range: "228f8-3a43cd-708051a3"
>
> HTTP/1.1 206 Partial Content
> Date: Thu, 15 Feb 2007 22:33:25 GMT
> Server: Microsoft-IIS/7.0
> Last-Modified: Wed, 14 Feb 2007 00:01:07 GMT
> ETag: "228f8-3a43cd-708051a3"
> Accept-Ranges: bytes
> Content-Length: 3400653
> Vary: User-Agent
> Content-Range: bytes 417792-3818444/3818445
> Content-Type: audio/mpeg
>
> the user-agent knew the Etag for the mp3, apache responds with this e-
> tag as well as the Content-Range, and Accept-Ranges headers
>
> make sure you generate the right headers with your php script and you
> should be fine, and then of course read from the correct offset!!




I suppose I should add that theres a great resource at http://
www.ampache.com
for instance in the play folder theres a file called index.php which
has these lines:

if ($start) {
debug_event('seek','Content-Range header recieved, skipping ahead ' .
$start . ' bytes out of ' . $song->size,'5');
$browser->downloadHeaders($song_name, $song->mime, false, $song-
>size);

fseek( $fp, $start );
$range = $start ."-". ($song->size-1) . "/" . $song->size;
header("HTTP/1.1 206 Partial Content");
header("Content-Range: bytes=$range");
header("Content-Length: ".($song->size-$start));
}

I havent determined whether it can handle streaming at just above the
average bit rate, which can be useful, but it seems an active project.
Although some of the code is a work in progress.

  Réponse avec citation
Vieux 16/02/2007, 14h02   #8
Dave
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: mod_rewrite & headers

Yes, that's pretty much how I've done this in .NET
I couldn't find much at http://www.ampache.com, sorry.

Just one other question...

I'm trying to resolve this rule:

RewriteRule ^test.html?s=([0-9]+)&b=([0-9]+) /folder$1/$2/test.html

where you would supply test.html?s=2&b=14016, which would rewrite the
url to: /folder2/14016/test.html

However, I can't get it to work using the above rule. Can anyone
please?

Thanks

Dave

  Réponse avec citation
Vieux 16/02/2007, 14h24   #9
shimmyshack
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: mod_rewrite & headers

On 16 Feb, 14:02, "Dave" <spambox.dcc...@gmail.com> wrote:
> Yes, that's pretty much how I've done this in .NET
> I couldn't find much athttp://www.ampache.com, sorry.
>
> Just one other question...
>
> I'm trying to resolve this rule:
>
> RewriteRule ^test.html?s=([0-9]+)&b=([0-9]+) /folder$1/$2/test.html
>
> where you would supply test.html?s=2&b=14016, which would rewrite the
> url to: /folder2/14016/test.html
>
> However, I can't get it to work using the above rule. Can anyone
> please?
>
> Thanks
>
> Dave


sorry my mistake: http://www.ampache.org

it seems strange to me that you are rewriting things this way when you
could just later the links.
However you can use
ReWriteCond %{QUERY_STRING} s=([0-9]+)&b=([0-9]+)
RewriteRule . /folder%1/%2/test.html [L,NS]
where the syntax %1 rather than $1 is because it matches against the
last conditions.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h58.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,23827 seconds with 17 queries