0

I searched for a solution to redirect from this URL:

www.domain.de/buynow.html?utm_source=test.de&utm_medium=banner&utm_campaign=demo

to this

www.domain.de/shop/buynow.html?utm_source=test.de&utm_medium=banner&utm_campaign=demo

Just for that one file should a rule generated. I Google a bit, but can’t find the solution I need with parameters that redirect all post/gets etc to /shop/file...

Any ideas? thanks!

I found this solution but it didn't work for my problem.

Community
  • 1
  • 1
  • answered here? http://stackoverflow.com/questions/864507/htaccess-url-rewrite-to-subdirectory – Ejaz May 05 '14 at 19:00

2 Answers2

1

Here's the simplest way that I know of.

RewriteEngine On
RewriteRule ^buynow.html /shop/buynow.html [L,R=301,QSA]

Here's what the different parts of the rewrite rule mean:

^buynow.html - the request starts with buynow.html

/shop/buynow.html - the destination

[L,R=301,QSA] - permanently redirect to the new location (R=301), pass the query string to the new location (QSA), and stop processing rewrite rules (L)

Adam H
  • 126
  • 3
0

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+buynow\.html\? [NC]
RewriteRule ^ /shop/%{REQUEST_URI} [R=301,L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • looks good, but all behind buynow.html? are parameters that are not static, they are dynamic and alltime different – user3605507 May 05 '14 at 19:08