Question: We have a dealer network that sells our products, as a bonus we give them an extra 25% off our products from the normal wholesale price if they put our products on their site.

We recently got hit with a Google manual penalty so we enlisted the help of "LinkDelete" to help us get rid of all the backlinks. Some of our dealer websites are in the list of bad backlinks they gave us. They told us this is because of duplicate content. 

What we do is give our dealers HTML snippets so they can just copy and paste it on their site. The HTML contains absolute URLs to pictures of our products, short descriptions, and links back to our website. 

We want our SEO rankings restored, so do we just tell our dealers to remove our links?

Answer: 
You are right to think about duplicate content when you are *changing* a URL structure and the old URLs are already indexed.

```
# My attempt to do so is giving me a 404 code sending me to domain2.
#RewriteCond %{QUERY_STRING} ^n=([A-Za-z0-9]+)$ [NC]
#RewriteRule ^index\.php$ http://domain.com/page/? [R=301,L]

```

In that case `http://domain.com/page/` would seem to be an invalid URL, but you are also removing the information contained in the query string and not passing it on to the "user friendly" URL (so all URLs are being redirected to the same invalid URL).

You also need to be careful of redirect loops, since you are internally rewriting to a URL that contains the query string (for your user friendly URL to work) but also need to redirect URLs that contain the query string to prevent duplicate content.

We can get around the redirect loop by checking against `%{THE_REQUEST}` which holds the full HTTP request as sent from the client and won't change after a rewrite.

So, for your first "page" URLs:

```
RewriteCond %{THE_REQUEST} \?n=([A-Za-z0-9]+)$
RewriteRule ^index\.php$ /page/%1? [R=301,L]

```

Note that the pattern `[A-Za-z0-9]` (taken from your example) in the URL is more restrictive than the pattern in your rewrites `[A-Za-z0-9-+_\s]` (which allows spaces!?) - both patterns should be the same, and not allow spaces. (Note that `THE_REQUEST` contains spaces, so the regex will need to change if you really really need this.)

**EDIT:** In view of the update below (to allow two parameters), I have added a `$` (position marker) in the above `RewriteCond` directive to signify the end of the string. This now *only* allows one URL parameter.

And the external redirects should come *before* the internal rewrites (which you appear to have done anyway).

**UPDATE:** For a second parameter (as mentioned in comments), add these additional directives:

```
RewriteCond %{THE_REQUEST} \?n=([A-Za-z0-9]+)&y=([A-Za-z0-9]+)$
RewriteRule ^index\.php$ /page/%1/%2? [R=301,L]

```

This checks for exactly two parameters (`n` and `y` in that order) and redirects accordingly.

(Note the edit to the first rule above for one parameter.)
Can you use a proxy in front of your Apache? Something like Varnish can do the rewriting for you, and as you separate concerns, you lower risk of building redirect loops and the likes. And that will speed up your website...

If you can't run a proxy on your server, maybe you can consider using external services than can do it for you, plus other things. The service I'm running does, and I think does it well. See the URL in my profile.