Jump to content

Same URL for all pages.


mmarif4u

Recommended Posts

Hi guys.

 

I wana to know some thing here.

I have a site where there are a lot of pages and directories.

 

For example site name is www.site.com (this is the index page).

Now if the user go to another pages for example click on the about link. How can i do this that the

site name appear in address bar remain the same as www.site.com not www.site.com/about.php

and so on for all pages.

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/53946-same-url-for-all-pages/
Share on other sites

You can use iframes.

 

<html>
<head>
<title>asdas</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<iframe src="index.php" name="body" frameborder="0" width="100%" height="100%">
Sorry, but your web browser does not support iframes
</iframe>
</body>
</html>

 

Each link mush have: target="body" before you end the first part of the tag.

 

You could also do:

 

<?php
//this file is index.php
$page = $_GET['page'];

if($page){
$dir = $_GET['dir'];

if(!$dir){
$file = "/home/yoursite/public_html/$page.php";
}else {
$file = "/home/yoursite/public_html/$dir/$page.php";
}

	if(file_exists($file)){
	include "$file";
	}else {
	include "/home/yoursite/public_html/main.php";
	}
}else {
include "/home/yoursite/public_html/main.php";
}
?>

 

In this case, your URLs must be:

 

About: /index.php?page=about

which will be: /home/yoursite/public_html/about.php

 

Something Else: /index.php?page=login&dir=user

which will be: /home/yoursite/public_html/user/login.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.