Dead domain re-direct
#1

I have two domains. Let's call them domain1 and domain2. Domain2 is an addon domain to domain1. I have moved all the files from domain1 to the domain2 folder inside domain1's file directory, and everything works perfectly, BUT.. I need to re-direct the old domain to the new one, so if someone goes to

www.domain1.net/hello
it will re-direct to
www.domain2.net/hello

and I don't just mean for certain URLs like above. I mean EVERY URL. Also, can this be done for images also? I've posted images on these forums (and elsewhere) from domain1 and would like them to still show.

If anyone could help me with this I'd appreciate it a heap. Thanks.
Reply
#2

Copied this off a website, currently using this to set my "/blog" as my main domain instead of the actual one.

PHP код:
<?php
/* Redirect browser */
header("Location: http://theos.in/");
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
Source: This Website
Reply
#3

If that's php code, that means it'll be in a php file, but users aren't going to get to that php file if they're going to a link to an image?
Reply
#4

Quote:
Originally Posted by MP2
Посмотреть сообщение
If that's php code, that means it'll be in a php file, but users aren't going to get to that php file if they're going to a link to an image?
I'm no expert or even have basic knowledge on PHP. I wish I could help ya out some more, I'll ****** around a bit
Reply
#5

It needs to be something in .htaccess I assume (I know NOTHING about this D:)

EDIT:

RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]

:D So simple!

Thanks for trying to help anyway.
Reply
#6

Quote:
Originally Posted by MP2
Посмотреть сообщение
It needs to be something in .htaccess I assume (I know NOTHING about this D

EDIT:

RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]

So simple!

Thanks for trying to help anyway.
Gonna keep that somewhere for future references. No problem, and thank you
Reply
#7

.htaccess files work for any file or directory, so you're deffinately right there. Redirecting an entire website to another URL with .htaccess works as followed:

Код:
Redirect 301 / http://www.my-other-website.com
Source: http://www.htaccessredirect.co.uk/

Rewriterule is to format the urls differently I think. (for example website.com/?p=page to website.com/page)
Reply
#8

Can i ask something .. it's about domains also. But how should link my payed domain to a VPS ..
Reply
#9

Quote:
Originally Posted by Michael@Belgium
Посмотреть сообщение
Can i ask something .. it's about domains also. But how should link my payed domain to a VPS ..
You need to setup a DNS client on your VPS. Then, you gotta setup nameservers both on the VPS and then your domain CP (Atleast, I had to do it on a Windows 2008 R2 server).
Reply
#10

Quote:
Originally Posted by Riddy
Посмотреть сообщение
You need to setup a DNS client on your VPS. Then, you gotta setup nameservers both on the VPS and then your domain CP (Atleast, I had to do it on a Windows 2008 R2 server).
Ok i got 2 nameservers on the domain already, but indeed i have to do something on the VPS. The OS of the VPS is Centos 5. And idk a dns client or dns server ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)