mmarif4u Posted June 2, 2007 Share Posted June 2, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/53946-same-url-for-all-pages/ Share on other sites More sharing options...
marcus Posted June 2, 2007 Share Posted June 2, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/53946-same-url-for-all-pages/#findComment-266703 Share on other sites More sharing options...
mmarif4u Posted June 2, 2007 Author Share Posted June 2, 2007 Thanks for reply. I know the GET method but now i want to get rid of it. Sample is www.site.com for index. www.site.com for about if he or she click on about. It mean that same url for all. Quote Link to comment https://forums.phpfreaks.com/topic/53946-same-url-for-all-pages/#findComment-266704 Share on other sites More sharing options...
marcus Posted June 2, 2007 Share Posted June 2, 2007 Your main answer is Iframes or Ajax. Quote Link to comment https://forums.phpfreaks.com/topic/53946-same-url-for-all-pages/#findComment-266705 Share on other sites More sharing options...
mmarif4u Posted June 2, 2007 Author Share Posted June 2, 2007 Can u give some example urls for ajax or iframe using this tecnique. Quote Link to comment https://forums.phpfreaks.com/topic/53946-same-url-for-all-pages/#findComment-266707 Share on other sites More sharing options...
marcus Posted June 2, 2007 Share Posted June 2, 2007 I don't know any AJAX, but you could easily Google something for it, and for iframes, I gave you an example in my first post. Quote Link to comment https://forums.phpfreaks.com/topic/53946-same-url-for-all-pages/#findComment-266709 Share on other sites More sharing options...
dj-kenpo Posted June 2, 2007 Share Posted June 2, 2007 for frames the answer was posted above by mgallforever, just read it. it's right there. the frame still uses get becuase the script has to know what file you want, it ain't magic! but it will be hidden from the user Quote Link to comment https://forums.phpfreaks.com/topic/53946-same-url-for-all-pages/#findComment-266715 Share on other sites More sharing options...
mmarif4u Posted June 2, 2007 Author Share Posted June 2, 2007 Thanks guys for ur replys and helpful posts. Quote Link to comment https://forums.phpfreaks.com/topic/53946-same-url-for-all-pages/#findComment-266719 Share on other sites More sharing options...
tail Posted June 2, 2007 Share Posted June 2, 2007 to target the frame, you must specify the target in your link like this: <a href="http://www.site.com" target="framename">link</a> Quote Link to comment https://forums.phpfreaks.com/topic/53946-same-url-for-all-pages/#findComment-266727 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.