2

Simple question I own a domain and from that domain i want to redirect users who opens my old domain URL to my New Domain URL.

1
  • Non-duplicate: Although, there is small amount of overlap between the questions, they are two different questions. In fact, apache doesn't necessary need to be involved in the redirect process, such as using DNS. Commented Apr 28, 2023 at 7:40

2 Answers 2

0

There's only one way to redirect a client - and that's by issuing a HTTP 3xx response to their browser that contains a redirect URL.

In this case, you'll want to issue a 301 code HTTP response (Permanent redirect) that contains the URL for your new domain. Only a HTTP server can do this.

Some DNS services are able to do this at your request - they will put one of their own hosts into the DNS request and redirect the client to a new URL on your behalf.

Gateway servers or CDNs (such as Cloudflare) are also able to redirect clients with 3xx HTTP responses that you can configure from their dashboards.

Otherwise, you'll want to configure your own server to do so. Point the DNS to that server's IP and configure Apache/Nginx/IIS to respond with a 3xx redirect code. As an example, here is an article on Apache 3xx redirects.

0

If you have cpanel you can do it under domains > redirects

If you don't, add the following to your .htaccess file

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^OLDDOMAIN\.com$ [NC]
RewriteRule ^(.*)$ http://NEWDOMAIN.com [R=301,L]

You may need to tweak it for https if you have an SSL certificate

Not the answer you're looking for? Browse other questions tagged or ask your own question.