mercredi 29 avril 2015

htaccess redirect to remove duplicate pages

I'm very new to this thing with htaccess rules.

I basically want two things.

  1. Redirect exampledomain.com to http://ift.tt/1qsWlqt. This works, the web host that is used had a FAQ page where they suggested the code I use. What doesn't work is this:

  2. Remove the way to access the "example" page from both "/index.php?p=example" and "/?p=example" to get better search engine ranks. If this means accessing that page from something like "/example", that's a bonus.

I basically want to remove the duplicate links that is caused by the /index.php-variant to get higher search engine ranks. Having prettier links isn't required, just a bonus, the most important thing is that I need to remove the duplicate links.

Here's the code anyway:

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^exampledomain.com$
RewriteRule ^(.*)$ http://ift.tt/1bz6TC8 [R=301]

RewriteRule ^([^/]*)\.html$ /index.php?p=$1 [L]
RewriteRule ^([^/]*)\.html$ /?p=$1 [L]

Have I misunderstood the [L/R=301/*]-flags totally?

EDIT: Ok, to clarify. I want to remove duplicate urls to get higher search engine ranks. What my code above apparently did was to add yet another url to access the same page. Since I only want one way, is there any way to redirect instead of just pointing the "prettified" link to the original?

When I think about it, would a redirection of http://ift.tt/1wq9Ufs to exampledomain.com do the trick?

Thanks guys so far, sorry for being bad at explaining. :)

Aucun commentaire:

Enregistrer un commentaire