Reza
Reza

Reputation: 880

How to redirect to another page using htaccess

I have 2 websites 1 old website and 1 new website. both are on different domains. now the old website had many urls like www.test.com/sadfd/dsf etc etc... all these urls are indexed by google. So when users click these urls I want them to redirect to www.newdomain.com

I had added a redirect using redirect in htaccess but then if the base url is www.domain.com/something/something it will redirect to www.newdomain.com/something/something.. but that url does not exist. I need all visits to redirect to www.newdomain.com

how can I do this?

Upvotes: 1

Views: 25

Answers (1)

Andréle
Andréle

Reputation: 336

I'm not the master of the .htaccess file but you can use this snippet, it redirects all pagerequests to the domain without adding the path:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?name-of-domain\.net$ [NC]
RewriteRule ^(.*)$ http://www.new-domain.net/ [R=301,L]

Upvotes: 0

Related Questions