Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Klatsch und Tratsch (https://www.delphipraxis.net/34-klatsch-und-tratsch/)
-   -   .htaccess: Problem bei Rewrite Conditions (https://www.delphipraxis.net/191972-htaccess-problem-bei-rewrite-conditions.html)

amigage 9. Mär 2017 11:31

.htaccess: Problem bei Rewrite Conditions
 
Hallo,

ich habe ein Problem mit meiner Rewrite Konfiguration.
zunächst möchte ich alle http:// Aufrufe nach https:// umleiten.
Das ist soweit kein Problem:

Code:
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
Nun möchte ich aber, dass eine bestimmte php-Datei - sagen wir special.php - NICHT umgeleitet werden soll.

Code:
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTPS} off
  RewriteCond %{REQUEST_URI} !(.*)special(.*)
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
Leider funktioniert das nicht. Es wird trotzdem auch die special.php auf https:// umgeleitet.
Kann mir jemand erklären, warum?

Besten Dank
amigage

Klaus01 9. Mär 2017 11:37

AW: .htaccess: Problem bei Rewrite Conditions
 
.. ist die Antwort vielleicht hier zu finden?

Grüße
Klaus

amigage 9. Mär 2017 13:42

AW: .htaccess: Problem bei Rewrite Conditions
 
Vielen Dank für den Link.

Die Lösung ist simpel:
Delphi-Quellcode:
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTPS} off
  RewriteCond %{REQUEST_URI} !special\.php
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
Das Problem war, dass mein Browser aufgrund von R=302 die Aufrufe gecached hat und somit den http Aufruf immer auf https umgeleitet hat.

Der Hinweis unter http://stackoverflow.com/questions/7...rewrite-script hat mich zum Ziel geführt.

Zitat:

If you need to do 301 (permanent) redirects -- do 302 instead during a testing period (until you are happy with the rule and results -- then change to 301) as modern browsers do cache 301 redirects .. so you may end up in frustrating situation when you have completely changed the rule (or even deleted it) but browser still do redirects. The only cure in such case -- clear browser cache and restart.


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:47 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz