Page 1 of 1

dumb question about redirects traps from index.html

Posted: Fri Jul 21, 2006 7:44 am
by lunarfish
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello. 

My webhosts don't recognise index.php and don't recognise php code in html files so I have to redirect from index.html to index.php with JavaScript. I wrote a little JavaScript function to test document.referrer. 

[syntax="javascript"]function changedirection() {
    var domain = 'lunarfish.co.uk';
    if (document.referrer.indexOf(domain) == -1) {
        window.location = "./lfread.php";
    } else {
        window.history.back();
    }
}
Problem is I can't do this without breaking the IE's back button because back doesn't populate document.referrer in IE. So I end up doing the worst thing in web politics and if you hit back on my homepage you end up on my homepage.

Can anyone tell me how I can get around this either PHP or JavaScript wise? Is there a PHP way to get rid of the whole index.html problem in the first place?

Thanks. Dan


feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Fri Jul 21, 2006 7:47 am
by Chris Corbyn
You might be able to use a .htaccess file to do the redirect, or even to specify the IndexFile ;)