SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Displaying .php pages as .html

    Hello,

    I know there is a way in which I could display my .php pages as .html by inserting some code on the .htaccess file but I forgot about it. I would appreciate if someone could post it for me.

    Also, how can I keep one url on the browser's navigation bar while visiting different sections of my site? For instance if the main url to my site were www.toly.com/home.php and I would go to www.toly.com/page1.php while I'm on page1.php I would like the browser's navigation bar to keep displaying www.toly.com/home.php as the url. I don't know if this can be done with the .htaccess file too.

    Thanks in advance.

  2. #2
    SitePoint Addict CeleronXL's Avatar
    Join Date
    Dec 2002
    Location
    United States of America
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well you could rename your pages to .html and then on the server set .html pages to run through the PHP parser.. o_O

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2002
    Location
    Perth, Australia
    Posts
    157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Toly

    First, the .htaccess code. It depends on whether you have PHP running as a CGI or as an Apache Module:
    Code:
    # For Apache Module
    <Files ~ ".*html$">
    ForceType application/x-httpd-php
    </Files>
    Code:
    # For CGI
    <Files ~ ".*html$">
    SetHandler cgi-script
    </Files>
    I think that will work. Also, if you are running PHP as a CGI (at least on Unix) you need to insert "#!/usr/bin/php" at the top of the PHP.html file.

    As for keeping the URL in the address bar constant, I think people do that just by enclosing their whole site in a FrameSet, but usually only when they have a domain the cheap way. Why do you want this? I would think it's more confusing for your visitors (I know I don't like it as much).
    Paul Davey
    webmaster for Whitford Church of Christ

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or you could simply use AddType in a .htaccess

    Code:
    AddType application/x-httpd-php .html

  5. #5
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks both for the code.
    Originally posted by bobbymac

    As for keeping the URL in the address bar constant, I think people do that just by enclosing their whole site in a FrameSet, but usually only when they have a domain the cheap way. Why do you want this? I would think it's more confusing for your visitors (I know I don't like it as much).
    I want this because I don't want people messing around with the variables I'm passing through the URL. Using frames would be a solution but not one I like so much.

    Thanks anyways.
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  6. #6
    SitePoint Zealot
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why dont you use form method="post" instead, then people cant mess with vars.
    Andy: Always Morphin Dwarfs

  7. #7
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AndyXL
    Why dont you use form method="post" instead, then people cant mess with vars.
    Sure they can, it just takes a bit more effort than changing a string in a URL. A post is a HTTP request like everything else.
    TuitionFree a free library for the self-taught
    Anode Says... Blogging For Your Pleasure

  8. #8
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why dont you use form method="post" instead, then people cant mess with vars.
    The variables will be passed using a form first but then they will be passed through the url.
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine


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
  •