gazivoda
gazivoda

Reputation: 63

Htaccess redirect different domains

I am trying to redirect all parked domains from my hosting to a specific page. Is there an efficient way of using 301 redirect in htaccess to do so. The example is below

www.domain1.com -> www.mydomain.com/domain1.com
www.domain2.com -> www.mydomain.com/domain2.com

If you have Idea or a tip how to extract root url and put it in a new url and then do a redirect please let me know, thanks.

Upvotes: 1

Views: 50

Answers (1)

anubhava
anubhava

Reputation: 786289

You may use this redirect rule in site root .htaccess or Apache config:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^$ http://www.example.com/%1 [L,R=301]

Upvotes: 1

Related Questions