icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » Hide your php pages.

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old September 17th, 2004, 3:04 PM   #1 (permalink)
I admire kayla
On a golden path...
 
Joined in Aug 2003
Lives in Saint Petersburg, Florida
Hosted on VPS5
478 posts
Gave thanks: 1
Thanked 1 Time in 1 Post
Thumbs up Hide your php pages.

This is a quick tutorial on how to hide your php pages.

First: Open up your favorite editor.

Let's say I have five pages: Main, Portfolio, About Me, Links, Contact Me

Let's start.
First, before all you will need this:
PHP Code:
<?php
switch($act) {
Replace act with anything you want. It will make it look like ?act=
The main page would be something like this:
PHP Code:
default:
include(
'main.php');
break; 
You will need to rename "main.php" to whatever you decide you want as your default page, Ok let's move on to portfolio,aboutme, etc.

It should Look something like this:

PHP Code:
case "portfolio":
include(
'port.php');
break;

case 
"about":
include(
'about.php');
break;

case 
"links":
include(
'link.php');
break;

case 
"contact":
include(
'contactme.php');
break; 
Now, whatever link you want to look like =contact etc. Place in case="HERE" (where here is). You must include the page also, Place it in include('here.php'); (where here.php is..)

You will now need to close it up, by doing this:
PHP Code:
};
?> 
The finishing touch would look like this:
PHP Code:
<?php
switch($act) {

case 
"portfolio":
include(
'port.php');
break;

case 
"about":
include(
'about.php');
break;

case 
"links":
include(
'link.php');
break;

case 
"contact":
include(
'contactme.php');
break;

default:
include(
main.php);
break;
?>
I would save this as "index.php"
Now all of your pages would be something like this:
http://demo.com/?act=portfolio
http://demo.com/?act=contact
http://demo.com/?act=
http://demo.com/?act=links
Here it goes, any questions or messups, reply
__________________
“The object of war is not to die for your country, but to make some other bastard die for his.” -George Patton
VPS5
Unleashed2k is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old September 17th, 2004, 3:24 PM   #2 (permalink)
Caffeine fiend
Comfy Contributor
 
pvera's Avatar
 
Joined in Aug 2004
Lives in Reston, Virginia
Hosted on pass15
270 posts
Gave thanks: 0
Thanked 0 times
If you want to be really devious about it, you can use mod_rewrite and set flat URLs like:

http://demo.com/portfolio goes to http://demo.com/?act=portfolio
http://demo.com/contact goes to http://demo.com/?act=contact
http://demo.com/links goes to http://demo.com/?act=links
pvera is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old September 17th, 2004, 3:25 PM   #3 (permalink)
Web Hosting Super Ninj4
Super #1
 
miakeru's Avatar
 
Joined in Sep 2003
Lives in Fullerton, CA
1,581 posts
Gave thanks: 0
Thanked 2 times
For those wondering, this would produce an effect like SurpassHosting.com uses with the top navigation links.

Also, allow me to correct a few things in the code. The final version had some things left out.

PHP Code:
<?php
switch($act) {

case 
"portfolio":
include(
'port.php');
break;

case 
"about":
include(
'about.php');
break;

case 
"links":
include(
'link.php');
break;

case 
"contact":
include(
'contactme.php');
break;

default:
include(
'main.php');
break;
};
?>
There was no ending quote (') around main.php, and there was no closing of the bracket up top.
miakeru is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old September 17th, 2004, 4:30 PM   #4 (permalink)
I admire kayla
On a golden path...
 
Joined in Aug 2003
Lives in Saint Petersburg, Florida
Hosted on VPS5
478 posts
Gave thanks: 1
Thanked 1 Time in 1 Post
woops, mybad
__________________
“The object of war is not to die for your country, but to make some other bastard die for his.” -George Patton
VPS5
Unleashed2k is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old September 17th, 2004, 11:06 PM   #5 (permalink)
L'Awesome Advocate
Super #1
 
Ancyru's Avatar
 
Joined in May 2004
Lives in .au
Hosted on Mango
2,423 posts
Gave thanks: 1
Thanked 5 times
How would you go about using mod_rewrite to change the links? I just don't know how to produce the coding to do so.
__________________
When I get sad, I stop being sad, and be AWESOME instead. True story.
Ancyru is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old September 17th, 2004, 11:25 PM   #6 (permalink)
Peaches!
Excelling Contributor
 
Joined in Jul 2003
Lives in Ottawa, Ontario, Canada
Hosted on Jose, Pass19
564 posts
Gave thanks: 0
Thanked 0 times
This should work:
Code:
RewriteEngine  on
RewriteBase    /
RewriteRule    ^(.*)[^/]$  index.php?page=$1  [T=application/x-httpd-php]
__________________
alex.honeywell [ seigousei.net - pass19, binuweb.com - jose ]
AlexH is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old September 17th, 2004, 11:41 PM   #7 (permalink)
Surpass Fan
On a golden path...
 
Joined in Jul 2004
372 posts
Gave thanks: 0
Thanked 0 times
think this is a stupid question....but why would someone want to hide their php pages?
__________________
"I am one of the few honest people that I have ever known” ~~Nick, Great Gatsby
---
Don't ever argue with idiots. They drag you down to their level and beat you with experience.
darkzeroman is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old September 17th, 2004, 11:44 PM   #8 (permalink)
I admire kayla
On a golden path...
 
Joined in Aug 2003
Lives in Saint Petersburg, Florida
Hosted on VPS5
478 posts
Gave thanks: 1
Thanked 1 Time in 1 Post
Looks professional.
__________________
“The object of war is not to die for your country, but to make some other bastard die for his.” -George Patton
VPS5
Unleashed2k is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old September 17th, 2004, 11:45 PM   #9 (permalink)
Web Hosting Super Ninj4
Super #1
 
miakeru's Avatar
 
Joined in Sep 2003
Lives in Fullerton, CA
1,581 posts
Gave thanks: 0
Thanked 2 times
Quote:
Originally Posted by darkzeroman
think this is a stupid question....but why would someone want to hide their php pages?
It basically prevents .php, .html, or .whatever from appearing in your address bar. I think it gives a more professional appearance for a business site, personally. I use it on one of mine.
miakeru is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On