Expand my Community achievements bar.

SOLVED

I want to set DNS redirect for site

Avatar

Level 2

Hi Team I want to set the redirection on xyz.com, all the pages of xyz.com will redirect to abc.com.

please let me know what and where do I need to write code. in vhost file.

 

Thank You in advance.

 

1 Accepted Solution

Avatar

Correct answer by
Level 7

Hi @Dear_AT 

In order to set the redirection on xyz.com, you would need to configure a rule in the Apache web server. The rule should check for any request made to xyz.com and redirect it to abc.com.

You can achieve this by adding the following rule in your Apache configuration file:

<VirtualHost *:80> 
   ServerName xyz.com 
   Redirect 302 / http://abc.com/ 
</VirtualHost>

Also,

You can do this by creating a dispatcher rule in your dispatcher configuration.

You can use a redirect rule such as this one:

RedirectRule ^/ http://abc.com [R=301,L]

 This rule will redirect all requests to xyz.com to abc.com.

View solution in original post

2 Replies

Avatar

Community Advisor

Hi @Dear_AT 

 

Try with this rule to redirect the old pages to new domain.

 

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
  RewriteCond %{HTTP_HOST} ^www.olddomain.com$
  RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
</IfModule>

  https://wpscholar.com/blog/redirect-old-domain-to-new-domain-via-htaccess/ 

Avatar

Correct answer by
Level 7

Hi @Dear_AT 

In order to set the redirection on xyz.com, you would need to configure a rule in the Apache web server. The rule should check for any request made to xyz.com and redirect it to abc.com.

You can achieve this by adding the following rule in your Apache configuration file:

<VirtualHost *:80> 
   ServerName xyz.com 
   Redirect 302 / http://abc.com/ 
</VirtualHost>

Also,

You can do this by creating a dispatcher rule in your dispatcher configuration.

You can use a redirect rule such as this one:

RedirectRule ^/ http://abc.com [R=301,L]

 This rule will redirect all requests to xyz.com to abc.com.