Re: [Hampshire] apropos PHP & web stuff

Top Page
Author: Hugo Mills
Date:  
To: Hampshire LUG Discussion List
Subject: Re: [Hampshire] apropos PHP & web stuff

Reply to this message
gpg: failed to create temporary file '/var/lib/lurker/.#lk0x58137100.hantslug.org.uk.9041': Permission denied
gpg: keyblock resource '/var/lib/lurker/pubring.gpg': Permission denied
gpg: Signature made Thu Apr 24 11:19:05 2008 BST
gpg: using DSA key 20ACB3BE515C238D
gpg: Can't check signature: No public key
On Thu, Apr 24, 2008 at 11:12:18AM +0100, John Lewis wrote:
> I have a file index.html in /var/www which is intended to redirect
> any attempt to open the URL http://startx.co.uk to
> http://startx.co.uk/Kingsclere to avoid exposing the 'index' to the
> world
>
> Originally I used a
>
> <head>
> <meta http-equiv="refresh" content="10: url=new_url" >
> </head>
>
> line to do the re-direction but I read this is deprecated and should
> be done with apache redirection. I have tried to fathom out how but
> failed.
>
> Having looked briefly at what PHP does in the 'PHP Manual' I wondered
> if there is a simple bit of php I could use to do the re-direction and
> to save me having to learn PHP just for this 'one liner' am asking
> for an example.


Use the header() function[1] to force a redirect in the HTTP
headers:

header("Location: http://startx.co.uk/Kingsclere");

This needs to be done before any other output gets sent. However,
if you control the server, use an Apache redirect, as below.

> Alternatively a simple explanation of how to use apache2 to do it
> would be gratefully accepted. I need to be told what files to edit on
> a debian lenny setup and what lines of code to remove/append.


I'd guess you're not using a virtual host configuration in Apache.
If that's the case, simply add:

RedirectPermanent / http://startx.co.uk/Kingsclere

to the end of your config file[2].

If you are using a virtual host, that line goes inside the VH
definition instead.

Hugo.

[1] http://uk.php.net/header
[2] http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirectpermanent

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
    --- There's an infinite number of monkeys outside who want to ---    
               talk to us about this new script for Hamlet               
                           they've worked out!