itebob
Goto Top

Platzsparende RewriteEngine-Regel

die Variante 1

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.de$ [NC]

  1. Variante 1
RewriteCond %{REQUEST_URI} ^/ordnerAlt/dateixyz.php$ [NC]
RewriteRule ^(.*)$ /ordnerNeu/dateixyz.php [L]
tut, was erwartet wird. Ich dachte, dass diese Regel
# Variante 2
RewriteCond %{REQUEST_URI} /ordnerAlt/^(.*)$ [NC]
RewriteRule ^(.*)$ /ordnerNeu/$1 [L]

die gleiche Wirkung hat, wie die Variante 1, dem ist aber nicht so. Was muss ich in der Variante 2 ändern, damit ich eine platzsparende Regel habe, die alle dateixyz.php abdeckt und ich mir sparen kann, für jede dateixyz.php eine separate Regel zu schreiben?

Diese
# Variante 3
RewriteCond %{REQUEST_URI} /ordnerAlt/^(.*)$.php [NC]
RewriteRule ^(.*)$ /ordnerNeu/$1 [L]

führt auch nicht zum Erfolg.

Content-Key: 281812

Url: https://administrator.de/contentid/281812

Printed on: April 19, 2024 at 00:04 o'clock

Mitglied: 122990
Solution 122990 Sep 02, 2015 updated at 14:52:17 (UTC)
Goto Top
Moin,
schau dir doch mal dein Regex in der RewriteCond an, der kann ja nicht funktionieren da du vor dem ^ noch Strings setzt, ^ bedeutet Matche den Anfang eines Strings!
Und auf Backreferences aus einer RewriteCond benutzt man das Prozentzeichen anstatt das Dollarzeichen
RewriteCond %{REQUEST_URI} ^/ordnerAlt/(.*\.php)$ [NC] 
RewriteRule ^(.*)$ /ordnerNeu/%1 [L]
Einfach mal durchlesen, steht da alles schön drin:
http://httpd.apache.org/docs/current/mod/mod_rewrite.html

Gruß grexit