Question: In my website I have the following categories url structure:

`/category.php?id=6` (id=6 is for internet category)

My SEO friendly url is like:

```
/category/6/internet/

```

The problem is it can be accessed in any of those forms, and because of that, I'm getting duplicate content on google.

So, I'm wondering how can I fix that.

Should I disallow on `robots.txt` any urls with `?` on it?

If so, how can I properly set it up?

Should I make a redirection "Permanently Moved" on `.htaccess`?

If so, how can I properly set it up?

My actual `.htaccess` for categories is like this:

```
RewriteRule ^category/([^/]*)/([^/]*)/$ category.php?id=$1&name=$2 [L]

```

Answer: 
You just need to set the canonical link tag in the head section of your pages

see <http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html>

and <http://support.google.com/webmasters/bin/answer.py?hl=en&answer=139394>

It will look something like

```
<link rel="canonical" href="http://www.example.com/category/6/internet/"/>

```

on the category 6 page

You could also do a 301 redirect for the category.php pages in your .htaccess by adding

```
RewriteRule ^category.php?id=([^&]*)&name=([^&]*) /category/$1/$2/ [R=301,L]

```

If you didn't want to go the route of rewriterules you could put the following code at the top of config.php:

```
if(preg_match('/^\/config\.php/', $_SERVER['REQUEST_URI'])){
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: /category/{$_GET['id']}/{$_GET['name']}");
    die();
}

```

Either way is up to you but I would use the rewriterule option to redirect to my SEO friendly URL If I were you
Or you get rid of the non-SEO url.

* always generate SEO url (you should do that anyway for)
* in category.php check if $\_SERVER['REQUEST\_URI'] is the seo one and if not redirect to it