...

View Full Version : Redirect ALL visitors ALWAYS to index.html



martinrab
01-21-2009, 09:32 PM
Hi,

I am just starting to understand JAVA Script a little bit to the point where I am able to modify scripts. Thing is now I can't find anything similar to what I need to modify :D

So maybe someone here can help me with the following:

I have a page which can be found in google which is nice. But people can find a lot of sub-pages as well which is nice from a PR point of view. Nevertheless I don't want people to jump in the middle. I want them all to start on index.hmtl and nowhere else. So is it possible to have all visitors who click on a search result for example in google to be redirected to index.html ? Maybe referrer based redirect? Can someone help me out on how this is done?

Thanks in advance. Martin :thumbsup:

jeddi
01-21-2009, 11:22 PM
Although you can do it with js its better to do this on the serverside.

Provided you have php running on your server
(and most do), then rename your pages to .php pages

Now you can use sessions.

Add this to all the non-index pages:


<?php
@session_start();

if (@$_SESSION['auth'] != "yes" ){
header("Location: index.php");
exit();
} // end if
?>


then on the index page add:


<?php
@session_start();
$_SESSION['auth'] = "yes";
?>

Of course all your internal links need to be changed to .php as well
no .htm ot .html can stay - all .php

OK :)

jeddi
01-21-2009, 11:25 PM
If you don't want to do the php route
you can use mod_rewrite rules in your htaccess file.

But the php route is easier and quicker.

martinrab
01-22-2009, 10:39 AM
Hey Jeddi,

thanks for your reply. I am in way over my head already I guess. For PHP hoes the same as for Java Script as far as I am concerned. I can read the code and modify it but don't really understand it yet. So you are saying that if I rename my fiels to *.php and paste your code in there "as is" all funcitonality will be the same as in my original html files but people are redirected to index? Will try right now! You are a champion! :D

martinrab
01-22-2009, 11:39 AM
Hey Jeddi, your second name is not by coincidence "GOD"? If not you are to me. What a cool solution. This actually now by coincidence solved another problem I had on the way..... THANKS THANKS THANKS! :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum