SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    Temecula, CA
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to Open File Without .PHP

    I would like to be able to direct people to www.somesite.com/thisarea without the .php (www.somesite.com/thisarea.php). I've tried saving the file without the php extension but it looses its php functionality on my localhost and can't be found at all on my site host. Is there a way to do this or am I just dreaming?

  2. #2
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Norway - Oslo
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you use apache add this to your .htaccess file (or the whatever-named-file in sites-available/):
    Code:
    <FilesMatch "^[a-zA-Z0-9]*$">
        ForceType application/x-httpd-php
    </FilesMatch>
    That forces every file that matches the regex pattern provided to be of mimetype that php uses, and what apache uses to fire up the php engine.
    This will force every file without an ending to be routed through the php parser, if that is not wanted simply use <Files thisarea> instead, for limiting it to that single file.
    Raymond Julin
    Developer: Hardware.no, Amobil.no, Gamer.no, Prisguide.no ...
    Owner: Kulturo.no

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    w/o ".php"

    The easiest way would be to have a folder named "thisarea" and have the file be the "index.php".
    Findus' suggestion will allow the server to parse files without the php extension as php files.
    Or maybe you mean something more like a "friendly URL" scenario?
    If so, this Sitepoint article should help http://www.sitepoint.com/article/sea...-friendly-urls


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
  •