sparkguitar05
Member
Posted 4 years ago #
I am starting a website and I would like to show a welcome page to users that are not logged on. Here's the ideal way I would like it to work.
If someone goes to http://www.mysite.com and they are not logged on, I want it to redirect to http://www.mysite.com/welcome.
If someone goes to http://www.mysite.com and they are already logged on, nothing happens and they stay on the home page.
Let me know if you figure out some way to do this.
Bit of a hack but - Within the index template before anything else happens you could do something like
<?php
if (!$user_ID)
{ header('Location: http://www.example.com/welcome');
exit;}
?>
sparkguitar05
Member
Posted 4 years ago #
It looks like you are on the right track, but it doesn't work right. When I go to http://www.example.com it redirects to http://www.example.com/welcome, but I get the following message in Firefox.
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
To clarify what I did: I copied your code to the very top of index.php on the root of my website and changed the URL from example.com to my own URL.
Let me know if I am doing something wrong.
sparkguitar05
Member
Posted 4 years ago #
Never mind I fixed it.
For those of you who want to know, the code is supposed to go in the theme index.php file, not the root index.php file.