Results 1 to 8 of 8

Thread: url masking

  1. #1
    Join Date
    Oct 2011
    Location
    London
    Posts
    41
    Thanks
    19
    Thanked 1 Time in 1 Post

    Unhappy url masking

    hi guys i have been trying for days i have made a simple site for a friend the problem im having is with the URL eg i start with /index.php (asks for login) after goes to /menu.php (make choice) /survey.php ect

    how can i just make it domain.com or domain.com/index.php=????? or just domain.com/index.php

    thanks all
    Last edited by TwitterRooms; 01-14-2012 at 01:05 PM.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You can't, using the files you have at the moment. If you want one URL (or one URL with ?...) then you need to have one file.

    You can use include() to use multiple files, and you can use conditional if statements to decide which page to include. So you don't need to literally put everything in one file, but you will need one central file that decides what to display.

    Although it is possible to, for example, check whether data was submitted and display a different page because of that, using the ?... format will be much easier and more reliable. Look up how to use "GET" variables in PHP. The URL format is easy, just use index.php?var=value&var2=value2 and so on. Then to access them you will use the $_GET array, so that you can use $_GET['var'] which will have a value of "value".
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. The Following User Says Thank You to djr33 For This Useful Post:

    TwitterRooms (01-11-2012)

  4. #3
    Join Date
    Oct 2011
    Location
    London
    Posts
    41
    Thanks
    19
    Thanked 1 Time in 1 Post

    Default

    Thanks I'll have a go

    What about .httacesses file can it be done with that?

  5. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Well, that depends on what you mean. You still need to get the information into the PHP somehow.

    You could use .htaccess with mod_rewrite to use 3 URLs but load only 1 file. But that's the opposite of what you said. I'm not really sure how mod_rewrite would help too much here. You could try to add some rules about the GET or POST data, but that's complicated and is probably best handled with PHP.

    I'm still not sure why you want this. What is "masking"? Do you mean that you want to hide the URL? It will still work the same way, so nothing will be hidden-- it will just have a new name. Or did you just want to rename it? If that's all, we can help find a way to do that.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. The Following User Says Thank You to djr33 For This Useful Post:

    TwitterRooms (01-11-2012)

  7. #5
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    If you want to "hide" the URL - it seems that may be what you're asking - you should be aware that doing so creates many usability problems. It also ruins bookmarking, search engine indexing, and can create many technical difficulties to work around.

    If you want to completely hide the URL, the best option is to use only one page and use AJAX to load the different content from the server when needed. (Although this still creates most of the problems I mentioned above. The URL is important! It should not be hidden, it should be used!)

  8. The Following User Says Thank You to traq For This Useful Post:

    TwitterRooms (01-14-2012)

  9. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Just to add to what traq said, even if you do hide the URL, it won't be "secure", so if you're using this for security, it's better to use another approach. If you just don't want users to randomly find the page (or go back to it), that is possible, but it's not going to really be secure.

    The other way to approach this would be to use a random "password" in the URL as part of a GET variable.
    page.php?code=123456789
    You could use sessions to generate this code and let it work only one time. If you really need a page to only load once, that's a good way to do it. Then if they don't have the right code, use a redirect to send them away from the page and exit; to stop more content from loading.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. The Following User Says Thank You to djr33 For This Useful Post:

    TwitterRooms (01-14-2012)

  11. #7
    Join Date
    May 2010
    Location
    Sacramento, CA
    Posts
    91
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Default

    have you checked out AJAX dynamic content loading into a <div> or using an iframe? Neither will be good for security but will accomplish a 'clean' look in the url..

  12. #8
    Join Date
    Oct 2011
    Location
    London
    Posts
    41
    Thanks
    19
    Thanked 1 Time in 1 Post

    Default

    i solved this problem by puting
    PHP Code:
    require_once('auth.php'); 
    at the top of all files
    then
    auth.php was like this
    PHP Code:
    <?php
        
    //Start session
        
    session_start();
        
        
    //Check whether the session variable SESS_MEMBER_ID is present or not
        
    if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
            
    header("location: login-form.php");
            exit();
        }
    ?>
    Thank you all for you help with this matter

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •