3

I want to 301 redirect home.html to the root to avoid duplicate content. I can do this like this:

RewriteRule ^/home.html$ / [NC,R=301]

However there is a legacy affiliate program that use home.html like this:

home.html?a=companyname

Is there a way to allow the affiliate links, but still 301 home.html?

user1059511
  • 257
  • 1
  • 4
  • 18
  • Incidentally, you need to remove the leading / from your match string (i.e., it should be `^home.html$`. Search [this page of the docs](http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html) for "leading slash" for further info. – daiscog Sep 14 '15 at 09:45

1 Answers1

0

The query string will be appended automatically. From the docs:

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.

Community
  • 1
  • 1
daiscog
  • 11,441
  • 6
  • 50
  • 62