|
Joined: Jan 2001
Posts: 374
Enthusiast
|
Enthusiast
Joined: Jan 2001
Posts: 374 |
Since cookies don't work (especially on the login page., if the bookmark URL to the forum was set to http://forum.de/or http://122.122.122.122/instead of http://www.forum.de/ (www. is needed!) and some of my users have difficulties now to login, I badly need a solution. I cannot fix all wrong links or bookmarks floating around on the web that are going to the forum. So I need a checking in THREADS whether the URL is used right, and if not, refresh the page with the URL fixed. - Is that possible?
|
|
|
|
Joined: Apr 2002
Posts: 1,768
Addict
|
Addict
Joined: Apr 2002
Posts: 1,768 |
You might try something like this: code: if ($_SERVER['HTTP_HOST'] != 'www.forum.de') { header('Location: http://www.forum.de/'); exit; } If your PHP version is earlier than 4.1.0, use $HTTP_SERVER_VARS instead of $_SERVER. I'm not sure if it will do what you want, or where it should be placed, but maybe it's a starting point. 
|
|
|
|
Joined: Jun 2001
Posts: 3,273
That 70's Guy
|
That 70's Guy
Joined: Jun 2001
Posts: 3,273 |
Looks like you hit the nail on the head Dave. Nice. 
|
|
|
|
Joined: Jan 2001
Posts: 374
Enthusiast
|
Enthusiast
Joined: Jan 2001
Posts: 374 |
Thanks, I will try your code. I also found a workaround, that I placed in login.php. I wonder which code is safer, probably my if statement, which uses THREADS code and is PHP independent. And your redirect code.. My workaround for the login.php page was: after: code: // -------------------------------- // require the proper language file require "languages/$w3t_language/login.php"; insert in login.php: code: // HACK URL correction if (!stristr(find_environmental('HTTP_REFERER'),"www.")) { echo <<<REDIR <html> <head> <meta http-equiv="Refresh" content="1;url={$config['phpurl']}/login.php"> </head> <body> </body> </html> REDIR; exit; } // Hack end
Last edited by caymuc; 06/08/2002 8:54 AM.
|
|
|
|
Joined: Jun 2001
Posts: 3,273
That 70's Guy
|
That 70's Guy
Joined: Jun 2001
Posts: 3,273 |
Your code is just fine too. Guess it's just a matter of choice now. 
|
|
|
|
Joined: Jan 2001
Posts: 374
Enthusiast
|
Enthusiast
Joined: Jan 2001
Posts: 374 |
Actually, my code had a problem  For all who consider using it, here is the code that I am now perfect with: code:
// HACK um richtige URL einzufuegen: $Right_Host = "www.mydomain.com"; //put your domain here! $Goto_URL = "http://" . $Right_Host . find_environmental('PHP_SELF'); if (!stristr(find_environmental('HTTP_HOST'),$Right_Host)) { header('Location: ' . $Goto_URL); exit; } // end Hack Belongs before anything else right to the top of the ubbt.inc.php
|
|
|
|
Joined: Nov 2001
Posts: 126
Junior Member
|
Junior Member
Joined: Nov 2001
Posts: 126 |
posted by caymuc: Actually, my code had a problem 
For all who consider using it, here is the code that I am now perfect with: code:
// HACK um richtige URL einzufuegen: $Right_Host = "www.mydomain.com"; //put your domain here! $Goto_URL = "http://" . $Right_Host . find_environmental('PHP_SELF'); if (!stristr(find_environmental('HTTP_HOST'),$Right_Host)) { header('Location: ' . $Goto_URL); exit; } // end Hack
Belongs before anything else right to the top of the ubbt.inc.php
Did that... Got this at the top of my forums.. Warning: Cannot add header information - headers already sent by (output started at /sky/www/dancesafe.org/html/ubbthreads/ubbt.inc.php:2) in /sky/www/dancesafe.org/html/ubbthreads/ubbt.inc.php on line 1674
|
|
|
|
Joined: Jan 2001
Posts: 374
Enthusiast
|
Enthusiast
Joined: Jan 2001
Posts: 374 |
Interesting, I will dig into that Ahm, where did you place the code. After the comments (what I want to say, after the opening "<?") and before other PHP code?
Last edited by caymuc; 06/20/2002 3:05 AM.
|
|
|
|
Joined: Nov 2001
Posts: 126
Junior Member
|
Junior Member
Joined: Nov 2001
Posts: 126 |
After the UBB intro/disclaimer text Right after where it said */
|
|
|
|
Joined: Oct 1999
Posts: 282
Enthusiast
|
Enthusiast
Joined: Oct 1999
Posts: 282 |
Hi, there's another solution using the .htaccess file. For me it works fine. Thats part of my .htaccess file residing in the forum-folder: /forum/.htaccesscode: RewriteEngine On RewriteBase / # Rewrite Rule for leading www RewriteCond %{HTTP_HOST} www.forum.de$ [NC] RewriteRule ^(.*)$ http://forum.de$1 [L] *edit* hmmm, just found out it won't work, if you try to access over www.forum.de/ubbtreads.php. Just calling www.forum.de works fine. But anything added to the domain after / does not. Any Apache experts here?  *edit*
Last edited by Maze; 06/21/2002 6:44 AM.
|
|
|
|
Joined: Jan 2001
Posts: 374
Enthusiast
|
Enthusiast
Joined: Jan 2001
Posts: 374 |
Is the problem gone if you switch it off (by putting a /* before and a */ after the hack)? I cannot see where this little 3 line hack could be the course of your problem. 
|
|
|
|
Joined: Nov 2001
Posts: 10,369
I type Like navaho
|
I type Like navaho
Joined: Nov 2001
Posts: 10,369 |
The hack worked just fine for me as posted.
But in the past I've learned that a blank line or space somewhere (when I copied and pasted) can cause trouble.
I usually go back and start over, and it fixes any warnings like this.
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 1,157
Joined: July 2001
|
|
Forums63
Topics37,575
Posts293,931
Members13,823
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|