Page 1 of 1

Auto redirect of all pages

Posted: Tue Aug 09, 2005 10:53 am
by phpJames
I am quite new to PHP, and have heard that there is a way of redirecting all files on my site to another.

For example, no matter whether the visitor tries to access http://www.mysite.com/shop.php or http://www.mysite.com/contact.php, or any other page, they'll always be redirected to http://www.myothersite.com/index.php

I simply want to catch all visitors to my old site, and immediately transfer them to my new one. I've heard it can be done by editing one file, rather than every file on the site. Can anyone please offer specifics?

Posted: Tue Aug 09, 2005 11:05 am
by Grim...
I think you might be talking about the .htaccess file.

For tutorials on htaccess, Google is your friend...

Posted: Tue Aug 09, 2005 11:08 am
by s.dot
if there's a single file you include in all of the pages of the old site

like include 'databaseinfo.php';
or
include 'header.php';

You could put a simple header location at the top of one of those files.

Code: Select all

header("Location: http://www.domain.com");

Posted: Tue Aug 09, 2005 11:22 am
by josh
Easy method
set the 404 page to index.php

more 'involved' method
write a rewrite rule for every old file, rewriting it to the index file

Posted: Tue Aug 09, 2005 11:36 am
by neophyte
redirect directive in .htaccess file.

Posted: Tue Aug 09, 2005 1:55 pm
by phpJames
Excellent, thanks a lot guys. That htaccess directive is exactly what I was looking for. :D