Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Fake extension

  1. #1
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    827
    Thanks
    93
    Thanked 18 Times in 18 Posts

    Fake extension

    I'm wondering, is it possible to create a fake extension for a file? E.g if a user goes to mysite.com/index.go it actually load index.php but the URL bar will still say index.go?

  • #2
    New Coder
    Join Date
    May 2012
    Location
    Mars
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yeah Just put this in your .htaccess file
    Code:
    AddType application/x-httpd-php .php .phtml .php3 .go

  • #3
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Or a second option would be to have something like this
    Code:
    RewriteEngine On
    RewriteRule (.+)\.go /$1.php
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #4
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    827
    Thanks
    93
    Thanked 18 Times in 18 Posts
    Code:
    RewriteEngine On
    RewriteRule (.+)\.go /$1.php
    That's way I wanna go, I don't actually want .go files I just want the URL to show that. However when i added this the .go files sent me to the root dir. The .go files are at a URL 'locahost/Dropbox/eg/new/index.go/' but they load the same page as just 'localhost'. Anyone know why it's doing that?

    EDIT: It works if I put the .htaccess file in the root folder not the sub dir one .

    However now i have a new question haha.

    Code:
    RewriteRule (.+)\.login /$1/login.php
    I need that rule to ignore the filename and just use the folders, so /sub1/sub2/index.login would actually load /sub1/sub2/login.php. Obviously atm its loading /sub1/sub2/index/login.php. I need it to ignore the filename, is that possible?

    EDIT 2: I came up with this "RewriteRule (.+)/(.+)\.login $1/login.php" Is that a good way to do it or could that be better?
    Last edited by tomharto; 05-23-2012 at 01:37 PM.


  •  

    Posting Permissions

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