Reputation: 2066
I have a duplicate urs like www.domain.com/en/article and www.domain.com/article ... they are both going to same page.
Now we are re-building the site and we would like to redirect duplicate urls like the above to one page without having to do it multiple times, like is there a regex or something of such.
This is the standard one I know: #Redirect 301 /login http://www.domain.com/index.php?option=login
Any suggestion?
Thanks in advance
Upvotes: 1
Views: 203
Reputation: 1
How to correctly implement -problem duplicate pages .htaccess
RewriteCond %{HTTP_HOST} ^eintro.pl(.*) [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.eintro.pl/$1 [R,L]
RewriteRule ^index.html$ http://%{HTTP_HOST}/$1 [L,R=301]
Upvotes: 0
Reputation: 4414
Try this
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/new_(.*)$
RewriteRule ^(en)?/?(.*)$ /new_$2 [R=301,QSA,L]
It will redirect:
www.domain.com/en/article
or www.domain.com/article
to www.domain.com/new_article
www.domain.com/en/another_article
or www.domain.com/another_article
to www.domain.com/new_another_article
www.domain.com/en/another_article2
or www.domain.com/another_article2
to www.domain.com/new_another_article2
and so on..
Upvotes: 0
Reputation: 785286
You can use this rule:
RewriteEngine On
RewriteRule (^|/)article/?$ /new_article [R=301,NC,L]
Upvotes: 2