watch.php?ch=v&id=32 redirect

Alles, was den Apache betrifft, kann hier besprochen werden.

watch.php?ch=v&id=32 redirect

Postby index » 05. February 2007 07:55

Hallo sicher seit ihr schon genervt von den vielen rewrite Fragen.
Ich habe seit 2 Tagen alles im Netz durchsucht, ein php Supportboard hat ebenfalls daran verzeifelt, nun seit ihr meine letzte Hoffnung.

Ich möchte folgende von der DB erzeugte Links weiterleiten
Code: Select all
http://localhost/video/videos/watch.php?ch=v&id=32
http://localhost/video/videos/watch.php?ch=v&id=33
usw

auf
Code: Select all
http://localhost/video/video_clips/delfine.html
http://localhost/video/video_clips/delfine1.html


Mir reicht es schon, wenn mir jemand ein Beispiel geben kann wie ich
Code: Select all
http://localhost/video/videos/watch.php?ch=v&id=32  auf
http://localhost/video/video_clips/delfine.html 
weiterleiten kann

folgendes führt zu keiner Weiterleitung

Code: Select all
RewriteEngine On
RewriteCond %{HTTP_REFERER}!^http://localhost/video/videos/watch.php?ch=v&id=32?$  [NC]
RewriteRule ^(.*)http://localhost/video/video_clips/delfine.html$1 [L,R=301]


ebenso dies nicht

Code: Select all
RewriteEngine On
RewriteRule ^watch.php?ch=v&id=([0-9]*)\.html$ localhost/video/video_clips/delfine.html [L]


Wäre klasse, wenn mir jemand helfen könnte

Liebe Grüße
Index
index
 
Posts: 23
Joined: 05. February 2007 07:35

Postby Wiedmann » 05. February 2007 09:30


Nur um Begriffsverwirrungen zu vermeiden...

Im HTML im Browser gibt es dann also folgenden Link:
http://localhost/video/video_clips/delfine.html

Wenn der User auf diesen Link klickt, soll dann tatsächlich dieses auf dem Server aufgerufen werden:
http://localhost/video/videos/watch.php?ch=v&id=32

Stimmt die Beschreibung so?
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby index » 05. February 2007 09:42

Hallo vielen Dank für deine Antwort

Der User klickt auf ein Vorschaubild eines Videos.
Daraus resultiert dieser von der Datenbank generierte Link unter dem das Video aufgerufen wird
Code: Select all
http://localhost/video/videos/watch.php?ch=v&id=32


Nun soll aber nicht das Video direkt aufgerufen werden, sondern diese Seite
Code: Select all
http://localhost/video/video_clips/delfine.html


Gebe ich den html Link in die DB direkt ein passiert nichts, da scheinbar nur Videoformate vom php Script in diesem DB Feld zugelassen sind.

Somit scheint mir als einzige Möglichkeit der Redirect per Rewrite Mod zu sein.

Code: Select all
also beim Aufruf von http://localhost/video/videos/watch.php?ch=v&id=32   weiterleiten auf  http://localhost/video/video_clips/delfine.html


Wäre super, wenn es dafür eine Lösung gäbe
index
 
Posts: 23
Joined: 05. February 2007 07:35

Postby Wiedmann » 05. February 2007 09:44

Also dann willst du sozusagen schöne URIs verkehrt haben?

Im HTML im Browser gibt es dann also folgenden Link:
http://localhost/video/videos/watch.php?ch=v&id=32

Wenn der User auf diesen Link klickt, soll dann tatsächlich dieses auf dem Server aufgerufen werden:
http://localhost/video/video_clips/delfine.html

Passt diese Darstellung jetzt?
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby index » 05. February 2007 11:15

Eigentlich ist es mir egal, was im Browser steht :lol:
Es ist nur wichtig, das die Umleitung klappt, da die Videos woanders liegen, als die Datenbank erwartet.

Von der Datenbak beim Upload des Videos generierter Link
Code: Select all
http://localhost/video/videos/watch.php?ch=v&id=32


Tatsächlicher Aufruf des Videos soll aber z.B hier sein
Code: Select all
http://www.xyz.com/video/video_clips/delfine.html


Hintergrund ist, das das Script auf einem anderen Server liegt, als die Videos.
index
 
Posts: 23
Joined: 05. February 2007 07:35

Postby Wiedmann » 05. February 2007 12:22

Eigentlich ist es mir egal, was im Browser steht

Hm, dir vielleicht. Eine mod_rewrite Lösung kann man nur entwickeln, wenn man weis was im Browser steht, und was dann daraus werden soll.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby index » 05. February 2007 12:30

Ok dann soll im Browser halt http://www.xyz.com/video/video_clips/delfine.html
stehen, wenn http://localhost/video/videos/watch.php?ch=v&id=32
angefordert wird, es muss aber auch dorthin weitergeleitet werden.

Es geht doch lediglich darum einen Redirect zu finden, der eine Url
http://localhost/video/videos/watch.php?ch=v&id=32 auf eine html Seite weiterleitet und nicht darum, das die URL suchmaschinenfreundlicher ist :?

Die klassischen bekannten Redirects können das leider nicht.
index
 
Posts: 23
Joined: 05. February 2007 07:35

Postby Wiedmann » 05. February 2007 12:46

Es geht doch lediglich darum einen Redirect zu finden, der eine Url
http://localhost/video/videos/watch.php?ch=v&id=32 auf eine html Seite weiterleitet,

Das wäre dann (.htaccess):

Code: Select all
RewriteEngine On
RewriteCond %{QUERY_STRING}  ^ch=v&id=32$
RewriteRule ^watch.php$ http://localhost/video/video_clips/delfine.html [R]
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby index » 05. February 2007 13:09

Ich weiss nicht was ich jetzt sagen soll, bin einfach sprachlos, es klappt.
Tausend Dank, dran habe ich mir nun seit Tagen die Zähne ausgebissen.

Vielen vielen Dank, damit ist die Woche gerettet :lol:
index
 
Posts: 23
Joined: 05. February 2007 07:35

Postby index » 05. February 2007 17:08

Nun ist doch noch ein kleines Problemchen aufgetaucht.
Wurde das Video vom User schon mal gesehen, wird der Link automatisch von
http://localhost/video/videos/watch.php?ch=v&id=32
in http://localhost/video/videos/watch.php ... ype=viewed

geändert und dann scheint der Redirect nicht mehr zu klappen.
Kann man den Code so ändern, das alles was hinter dem ch=v&id=32 kommt mit umgeleitet wird?

Vielen Dank für deine super Hilfe
index
 
Posts: 23
Joined: 05. February 2007 07:35

Postby Wiedmann » 05. February 2007 17:15

In der Condition das abschliessende Dollarzeichen ("$") weglassen.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby index » 05. February 2007 18:21

Jetzt klappt es prima, nochmals vielen vielen Dank :D
index
 
Posts: 23
Joined: 05. February 2007 07:35

Postby index » 06. February 2007 10:35

Hallo darf ich nochmal kurz was fragen :oops:

Gibt es eine Begrenzung, ab wann die Umleitung mit .htaccess eventuell nicht mehr korrekt arbeitet?
In nachfolgendem Code werden 2 Umleitungen wo völlig anders hingeleitet
als angegeben oder habe ich irgendwo Mist gebaut :roll: .

RewriteCond %{QUERY_STRING} ^ch=v&id=20
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_cl ... flores.htm [R]
RewriteCond %{QUERY_STRING} ^id=20
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_cl ... flores.htm


==>> wird ansatt wie angegeben .......bali_flores.htm hierhin umgeleitet http://66.197.217.248:81/video/video_cl ... unaken.htm

RewriteCond %{QUERY_STRING} ^ch=v&id=16
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_cl ... lombok.htm [R]
RewriteCond %{QUERY_STRING} ^id=16
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_cl ... lombok.htm [R]


und ==>> .......tauchen_sued_lombok.htm wird hierhin umgeleitet http://66.197.217.248:81/video/video_cl ... n_ubud.htm


Code: Select all
RewriteEngine On
RewriteCond %{QUERY_STRING}  ^ch=v&id=32
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_2fish_diving.htm [R]
RewriteCond %{QUERY_STRING}  ^id=32
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_2fish_diving.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=33
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_dugon.htm [R]
RewriteCond %{QUERY_STRING}  ^id=33
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_dugon.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=34
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_baliaga.htm [R]
RewriteCond %{QUERY_STRING}  ^id=34
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_baliaga.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=14
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/animals.htm [R]
RewriteCond %{QUERY_STRING}  ^id=14
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/animals.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=13
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/about_wallacea.htm [R]
RewriteCond %{QUERY_STRING}  ^id=13
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/about_wallacea.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=12
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/about_anggun.htm [R]
RewriteCond %{QUERY_STRING}  ^id=12
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/about_anggun.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=11
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/delfine.htm [R]
RewriteCond %{QUERY_STRING}  ^id=11
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/delfine.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=10
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/bluebay_diving.htm [R]
RewriteCond %{QUERY_STRING}  ^id=10
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/bluebay_diving.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=9
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/barong.htm [R]
RewriteCond %{QUERY_STRING}  ^id=9
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/barong.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=8
RewriteRule ^watch.php$ http://66.197.217.248:81//video/video_clips/video_alam_anda.htm [R]
RewriteCond %{QUERY_STRING}  ^id=8
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_alam_anda.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=7
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_ayu_tamansari.htm [R]
RewriteCond %{QUERY_STRING}  ^id=7
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_ayu_tamansari.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=6
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_bratan.htm [R]
RewriteCond %{QUERY_STRING}  ^id=6
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_bratan.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=5
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/bluebay_resort.html [R]
RewriteCond %{QUERY_STRING}  ^id=5
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/bluebay_resort.html [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=4
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_2fish_resort_lembeh.htm [R]
RewriteCond %{QUERY_STRING}  ^id=4
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_2fish_resort_lembeh.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=3
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_2fish_diving_lembeh.htm [R]
RewriteCond %{QUERY_STRING}  ^id=3
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_2fish_diving_lembeh.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=2
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_2fish_resort_bunaken.htm [R]
RewriteCond %{QUERY_STRING}  ^id=2
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_2fish_resort_bunaken.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=15
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_faszination_bali.htm [R]
RewriteCond %{QUERY_STRING}  ^id=15
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_faszination_bali.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=17
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/rundreise_bali_tauchen.htm [R]
RewriteCond %{QUERY_STRING}  ^id=17
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/rundreise_bali_tauchen.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=18
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/komodo_flores.htm [R]
RewriteCond %{QUERY_STRING}  ^id=18
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/komodo_flores.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=20
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/bali_flores.htm [R]
RewriteCond %{QUERY_STRING}  ^id=20
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/bali_flores.htm [R]RewriteCond %{QUERY_STRING}  ^ch=v&id=19
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/tauchen_sulawesi.htm [R]
RewriteCond %{QUERY_STRING}  ^id=19
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/tauchen_sulawesi.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=1
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_affen_ubud.htm [R]
RewriteCond %{QUERY_STRING}  ^id=1
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/video_affen_ubud.htm [R]
RewriteCond %{QUERY_STRING}  ^ch=v&id=16
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/tauchen_sued_lombok.htm [R]
RewriteCond %{QUERY_STRING}  ^id=16
RewriteRule ^watch.php$ http://66.197.217.248:81/video/video_clips/tauchen_sued_lombok.htm [R]


Ich habe zwar gefunden das mit dem RewriteOptions maxredirect= die Anzahl auf 10 per default begrenzt sein soll, aber diese Zeile gibt es in meiner config nicht, somit sollte doch auch keine Begrenzung existieren oder? Ausserdem dürfte sich die Anzahl dann doch nur auf gleichzeitige Redirects beziehen, da ja eine Endlosschleife verhindert werden soll
index
 
Posts: 23
Joined: 05. February 2007 07:35

Postby Wiedmann » 06. February 2007 13:00

RewriteCond %{QUERY_STRING} ^ch=v&id=20

Bei einem Querystring der dazu passt, passt natürlich auch diese Condition:

RewriteCond %{QUERY_STRING} ^ch=v&id=2

Da du ja nur die Übereinstimmug ab Anfang überprüfst. Wenn wenn diese hier zuerst aufgeführt ist, wird dann auch dir hier zugehörige Rule genommen.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby index » 06. February 2007 13:09

Das hatte ich befürchtet.

Jetzt wo du es schreibst fällt mir allerdings wie Schuppen von den Augen :lol: , das dies nur der Fall ist, wenn die kleinere ID vor der grösseren in der .htaccess abgefragt wird.

Also dürfte es am einfachsten sein, die grössten ID´s zuerst abfragen zu lassen.

Mal schauen ob ich da richtige denke

Danke schön
index
 
Posts: 23
Joined: 05. February 2007 07:35


Return to Apache

Who is online

Users browsing this forum: No registered users and 22 guests