dumb question about redirects traps from index.html

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lunarfish
Forum Newbie
Posts: 2
Joined: Fri Jul 21, 2006 6:24 am

dumb question about redirects traps from index.html

Post 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]
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You might be able to use a .htaccess file to do the redirect, or even to specify the IndexFile ;)
Post Reply