How to redirect to any domain [duplicate]
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.
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.
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
Comments
Post a Comment