0

My goal is to redirect from /kontaktaufnehmen/kontakt.html to /auftragsverwaltung/kontakt/?type=1 and the parameters must be added to the new path.

I tried

Redirect permanent /kontaktaufnehmen/kontakt.html /auftragsverwaltung/kontakt/?type=1

but the parameters are not added to the redirected path. Without ?type=1 the parameter will be added.

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
kimomat
  • 2,211
  • 23
  • 37
  • Which are the parameters? – Felipe Alameda A Jan 18 '13 at 12:48
  • the other parameters doesnt matter, because all parameters must be added to the url. Example: /kontaktaufnehmen/kontakt.html?test=1 must be redirected to /auftragsverwaltung/kontakt/?type=1&test=1 – kimomat Jan 18 '13 at 12:57
  • They do matter because they seem to be in a query. If that is the case, the flags should include `QSA`. Example [L,QSA]. That way the incoming query will be appended to the query added in the rule. I am just guessing though. It will help to see the rules you have now and one example of a complete incoming URL to have a better idea. – Felipe Alameda A Jan 18 '13 at 13:04

1 Answers1

1

Try:

RewriteEngine On
RewriteCond %{QUERY_STRING} !type=1
RewriteRule ^/?kontaktaufnehmen/kontakt.html /auftragsverwaltung/kontakt/?type=1 [L,R=301,QSA]

RewriteCond %{QUERY_STRING} type=1
RewriteRule ^/?kontaktaufnehmen/kontakt.html /auftragsverwaltung/kontakt/ [L,R=301]

The important thing here is the QSA flag, which means whatever query string that's already there gets appended. The mod_alias directive Redirect won't do this for you. The second rule is simply a redirect because it sees that the type=1 query string is already there so it won't add another.

Jon Lin
  • 142,182
  • 29
  • 220
  • 220