Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 37

Thread: URLS like: index.php?page=page1 ???

  1. #21
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Look into mod_rewrite with .htaccess.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  2. #22
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    My server doesn't allow .htaccess .... Thanks anyway though
    - Mike

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

    Default

    At that point, (and even with the php), really... why?
    It's not worth it for this.
    There are easier ways, and redirecting the browser, even using headers, can't be good practice for no reason.

    It's a cool idea... but you're just making extra work for yourself
    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

  4. #24
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    The arrays, and for-loops were good PHP practice for me anyway
    - Mike

  5. #25
    Join Date
    Aug 2006
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry, I only saw the first page!!!
    Last edited by costas; 10-20-2006 at 01:46 PM.

  6. #26
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mburt
    I've read that post, I couldn't understand it.
    Then ask about it. I can't help people understand something if they never say that there's a problem in the first place.

    By the way, you're in for a pleasant surprise, later.

    What's a URI?
    A Uniform Resource Identifier. URIs are a superset of URLs (Uniform Resource Locator) and URNs (Uniform Resource Name). That is, all URLs are URIs.

    A Locator not only identifies a resource, but also indicated how to access it by specifying its location (for example, its network address)


    Quote Originally Posted by djr33
    Quote Originally Posted by mburt
    Quote Originally Posted by Twey
    However, and URL like /guestbook is still better.
    How would I be able to use such a URL?
    Index page in /guestbook directory.
    Again (I mentioned this in the thread I cited), the URI for such a thing would end in a slash:

    &#160;&#160;http://www.example.com/guestbook/

    Using a separate directory for every single document isn't practical.


    Quote Originally Posted by mburt
    My server doesn't allow .htaccess
    Thankfully, and here's the surprise, it doesn't need to. In your case, it would seem that the MultiViews option (one of the content negotiation mechanisms I discussed) is already enabled.

    Just as a random example, consider your Basic Calendar script (you misspelt the heading, by the way). The URL for that ends:

    &#160;&#160;/scripts/basic_calendar_root.htm

    However, it can also be accessed using:

    &#160;&#160;/scripts/basic_calendar_root

    Why? When the request is received, no file, redirect rule, or anything else is found. However, because MultiViews is enabled, the server searches for files that begin with that name. When it finds basic_calendar_root.htm, it checks to see what type it is (text/html), and whether the browser making the request will accept it (it will). As a result, it returns that same file.

    If there are multiple matches, the server negotiates between them, finding the best match for the client based on language, encoding, type, etc. This allows for multiple representations that vary based on filename, using the name to distinguish one from another (for example: index.html.en, text/html, English; index.html.fr, text/html, French).

    The same thing can apply to your PHP files (assuming that they really need to be PHP, now): /resources.php can be accessed as /resources.

    Unfortunately, your host has configured PHP in the unfriendly way by MIME type, rather than handler, but it shouldn't be a problem. Moreover, with scripts.php, using the URL ending /scripts would result in a redirect to the directory with the same name. You'd either have to change the directory name or place an index file in that directory.


    Mike
    Last edited by mwinter; 10-20-2006 at 01:25 PM.

  7. #27
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Holy crap... how did that happen? When you type in the url for mburt.mb.funpic.org/resources, it automatically went there... you're a complete genius. The process of this did advance my PHP a little more though. But again, thanks for all the help
    - Mike

  8. #28
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mburt
    Holy crap... how did that happen?
    You're host enabled the MultiViews option. It's actually part of the default configuration for user directories (http://www.example.com/~username/). Either that directory structure is used internally, or they enabled it for all virtual hosts.

    I thought I'd give it a shot and tried it.


    By the way, you might want to re-read the last paragraph of my post as you might have been reading it whilst I was editing.

    Mike

  9. #29
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Yes, I changed scripts.php to scripts_page.php. I realized it was already a directory, and that it would take me to the index of the directory. Thanks.
    - Mike

  10. #30
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    Construct the page in html and then use this and change/add to your taste:

    PHP Code:
    <?php

    //Copy and paste the HTML that is the same in all your pages (the header and footer) into new files and name them header.inc and footer.inc.
    //They will be included at the complete top and bottom of your pages, so you will only have to edit these 2 files if you want to change your layout.

    include('header.inc');

    if(!
    $_SERVER['QUERY_STRING']) { ?>

    //Paste here the HTML coding you have on your main page. This is what people will see when they go to index.php, without any ?section bit after it.

    <? } elseif ($_SERVER['QUERY_STRING'] == "about") { ?>
    //Paste here your HTML code on the About page (without the header and footer code, obviously).

    <? } elseif ($_SERVER['QUERY_STRING'] == "rules") { ?>
    //Paste here your HTML code on the Rules page (without the header and footer code, obviously).

    <? } elseif ($_SERVER['QUERY_STRING'] == "join") { ?>
    //Paste here your HTML code on the Join page (without the header and footer code, obviously).

    <? } elseif ($_SERVER['QUERY_STRING'] == "codes") { ?>
    //Paste here your HTML code on the Codes page (without the header and footer code, obviously).

    <? } elseif ($_SERVER['QUERY_STRING'] == "members") { ?>
    //Paste here your HTML code on the Members page (without the header and footer code, obviously).

    <? } elseif ($_SERVER['QUERY_STRING'] == "extra") { ?>
    //Paste here your HTML code on the Extra page (without the header and footer code, obviously).

    <? }  
    include(
    'footer.inc'); ?>
    Whatever you save this as is what they will be. If you save this script as "index.php", you will have "index.php?about", "index.php?rules", "index.php?join", etc.

    You can also change some of the code to make it so it is like "index.php?act=about" by doing the following:

    "elseif ($_SERVER['QUERY_STRING']" or "if(!$_SERVER['QUERY_STRING']" can be changed by replacing "SERVER" with "GET" and "QUERY_STRING" to what you want it to be after the "?"...
    e.g.
    ($_GET['act'] == "about") on "index.php" will make the url appear as "index.php?act=about"

    On forum boards like this they do that... this page is "showthread.php?t=14133", they used "t" as "thread"
    Last edited by motormichael12; 11-10-2006 at 10:58 PM.

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
  •