CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Redirect if attempting to view an includable page

Print topic Send  topic

Author Message
datadoit.com
Posted: 08/16/2007, 7:12 PM

CCS3.1, PHP5, MySQL5

Does anyone know of a magical way to redirect the page if someone
attempts to view an includable page directly?

Ex: Someone, for whatever crazy reason, attempts to browse to
http://www.mywebsite.com/includes/header.php, so I want to redirect them
to the index.php page instead. However, header.php still needs to work
normally as an includable page.

Would prefer something that could be put somewhere in Common.php, and
not have to update every single includable page.

Gracias.
wkempees


Posts: 1679
Posted: 08/17/2007, 5:14 AM

Nice one.
You would probaly test for the PHP_SELF not being the name of the include file.
in which case you redirect.

Quote :
Server variables: $_SERVER

....
'PHP_SELF'

The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.


Just quick of the back of the head.

Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.