cancel
Showing results for 
Search instead for 
Did you mean: 

mod rewrite redirection on ccgi server

BJepson
Grafter
Posts: 34
Registered: ‎15-08-2007

mod rewrite redirection on ccgi server

Having had a domain hosted on both html anf ccgi servers I have now moved it completely to the ccgi server and adjusted the DNS appropriately.  This all works.
I now want to use a mod rewrite rule to force anyone accessing using the old ccgi address to change to the newly setup www address.
This is the rule I am using:
RewriteEngine On 
RewriteBase /
RewriteCond %{HTTP_HOST} ^ccgi\.scsc\.org\.uk [nc]
RewriteRule ^/(.*) http://www.scsc.org.uk/$1 [R=301,L]

But this does not work.  I have tried several variation all to no effect.  Other rewrites (not using the option work okay) just not the re-direct.
Help!
5 REPLIES 5
glyndev
Grafter
Posts: 620
Registered: ‎31-07-2007

Re: mod rewrite redirection on ccgi server

You do not need to use mod rewrite for this.
Raise a ticket asking support to point www.domainname. Huh to your cgi space. They will then set up the dns records for the domain.
jelv
Seasoned Hero
Posts: 26,785
Thanks: 971
Fixes: 10
Registered: ‎10-04-2007

Re: mod rewrite redirection on ccgi server

How does that stop anyone keying ccgi... in to their browser or using a bookmark of the ccgi address? Huh
jelv (a.k.a Spoon Whittler)
   Why I have left Plusnet (warning: long post!)   
Broadband: Andrews & Arnold Home::1 (FTTC 80/20)
Line rental: Pulse 8 Home Line Rental (£14.40/month)
Mobile: iD mobile (£4/month)
glyndev
Grafter
Posts: 620
Registered: ‎31-07-2007

Re: mod rewrite redirection on ccgi server

Sorry I misread the OP.
Been looking and wonder if this script http://naterocks.com/php-coding/site-moved-script would be of use.
It gives a warning message and reminds people to update favourites
ffupi
Grafter
Posts: 370
Registered: ‎01-08-2007

Re: mod rewrite redirection on ccgi server

How did you do it?
BJepson
Grafter
Posts: 34
Registered: ‎15-08-2007

Re: mod rewrite redirection on ccgi server

Quote from: ffupi
How did you do it?

I gave up on the Mod Rewrite, it still doesn't work.  Instead I have found you can do the same thing in PHP.
if ($_SERVER["HTTP_HOST"] == "http://old.domain") {
  header ("HTTP/1.1 301 Moved Permanently");
  header ("Location: http://new.domain");
  exit;
}
// syntax not checked, working from memory

Better than using Javascript as suggested in Davenports' link since it informs search engine crawlers that it is a permanent move not just a redirection.
I still don't know why the mod rewrite didn't work!
The only other clue was that ....
A later re-write in the same .htaccess changed .htm into .php, but didn't force a redirect .  This has always worked.  But when I tried to access the site using http://ccgi.domain/somefile.htm the whole thing got changed to http://www.domain/somefile.php and treated as if the flag was set (ie the rewritten URL was sent back to the client browser and a new request initiated).
So the rewrite from ccgi to www was working on its own, it just wasnt being send back to the client so the site move was not being seen.  Must be something quirky in the PH server setup!