Rewrite / Variablenübergabe

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

Rewrite / Variablenübergabe

Postby palinopsia » 03. December 2010 12:21

Hallo,

ich habe in meiner .htaccess folgende Rewrite-Rules

RewriteRule ^([^/\.]+)/?$ index.php?section=$1 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?section=$1&page=$2 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?section=$1&page=$2&subpage=$3 [L]
...

um URLs wie example.com/Kategorie/Unterkategorie/Seite zu ermöglichen.

Wie muss ich meine Konfiguration ändern, damit auch die Übergabe spezieller Variablen via GET klappt?

Also damit z.B. example.com/Suche/?query=suchwort&category=all funktioniert (in index.php sollten dann $_GET["section"], $_GET["query"] und $_GET["category"] entsprechend gesetzt sein.)

Besten Dank schon mal!
palinopsia
 
Posts: 3
Joined: 07. August 2010 13:13

Re: Rewrite / Variablenübergabe

Postby Nobbie » 03. December 2010 13:14

Indem Du bei den Flags noch den Wert "QSA" mit angibst (QSA = query string append).

Siehe http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

Modifying the Query String

By default, the query string is passed through unchanged. You can, however, create URLs in the substitution string containing a query string part. Simply use a question mark inside the substitution string to indicate that the following text should be re-injected into the query string. When you want to erase an existing query string, end the substitution string with just a question mark. To combine new and old query strings, use the [QSA] flag.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: Rewrite / Variablenübergabe

Postby palinopsia » 03. December 2010 13:36

Thx, genau das hatte ich gesucht
palinopsia
 
Posts: 3
Joined: 07. August 2010 13:13


Return to Apache

Who is online

Users browsing this forum: No registered users and 127 guests