How to redirect a domain without changing the URL

Mihai B.

Well-known member
Registered
Joined
Apr 19, 2016
Messages
243
Points
18
I have old domain and already got around 50 articles on it, now I want to move to a new site but I don't k now to to redirect URLs from old domain to new domain. Does anyone have a solution for this?
 

MooseLucifer

Well-known member
Registered
Joined
May 20, 2016
Messages
149
Points
28
You can use these codes to redirect your URLs/domains if wanted

Redirect and keep everything after the URL

Code:
RewriteCond %{HTTP_HOST} ^DomainA.com
RewriteRule ^(.*) http://DomainB.com/$1 [P]
Redirect a domain to a specific url

Code:
RewriteCond %{HTTP_HOST} ^DomainA.com
RewriteRule ^(.*) http://DomainB.com/PathToPageHere [P]

Re-directing an IP address

Code:
# Redirect all IP address (replace the ## with the IP address numerals) to same http://domain_name.com
RewriteCond %{HTTP_HOST} ^##\.##\.##\.##
RewriteRule (.*) http://domain_name.com/$1 [R=301,L]
Hope it helps!
 

LJSHost

Well-known member
Hosting Provider
Registered
Joined
Jul 5, 2016
Messages
1,031
Points
63
Hi Mihai,

This can be done in a couple of ways:

cPanel Method:

Domains > Redirects > Select your domain and enter the new URL in the ' Redirects To ' box > select redirection options > click Add


.htaccess method

Create a file in your document root called .htaccess

RewriteEngine On

# Redirect Entire Site to New Domain
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]


Change olddomain.com to your old domain name and newdomain.com to your new domain name. This will redirect requests for the www. and non www. to your new domain.
 

KevinHV

Member
Registered
Joined
Sep 8, 2016
Messages
57
Points
8
Give a try with below code.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Welcome</title>
<script type="text/javascript">
<!--
   window.location="https://forumweb.hosting";
//-->
</script>
</head>
<body>
</body>
</html>

This will not change URL in address bar. but it will goes to domain configured at window.location
 

wlraider81

Member
Registered
Joined
Aug 15, 2016
Messages
22
Points
3
wlraider81
This way is good but not convenient if the user don't know about codes on their web system, where to put.
Also it seems works on a single URL, if we want for whole ULRs on a site then it can need httacces to solve this problem.
 
Older Threads
Latest Threads
Replies
0
Views
26
Replies
0
Views
41
Replies
1
Views
43
Replies
0
Views
237
Recommended Threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top