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
  1. #1
    New Coder
    Join Date
    Aug 2011
    Location
    England
    Posts
    23
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Question no file extension for pages? (like Google)

    Hi there!

    I was wondering how google uses a certain file type (without the extension) and successfully displays the webpage?.

    For example: http://www.google.com/webhp
    there is no file extension used in the URL (such as webhp.php, webhp.html, etc.)
    and there is no directory used as well (I tested http://www.google.com/webhp/ and the 404 page displayed instead of the Google homepage).

    I was wondering on how this is done? especially in cPanel?.
    I would like to use this for all of my pages if I could (for example: the index page, the login page, etc.).

    At the moment I'm a new programmer experimenting with new things and I took a deep interest into having no file extensions on the pages.

    If you would like to see my failing experiment, the URL is here. Unfortunately, the page content is represented as text, not HTML.

    Thanks for taking the time to read!

  • #2
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    it's done by sending correct mime-type in header.
    that's how you can go to example.com/document.php and get an image, audio file, excell document or whatever.
    btw file extention is used only in windows. in any other system it's just a part of file name not derminating how contents will be treated

  • #3
    New Coder
    Join Date
    Oct 2012
    Location
    Under a Roof
    Posts
    14
    Thanks
    2
    Thanked 1 Time in 1 Post
    Just add .htaccess file to the root folder of your site(for example, /home/domains/domain.com/htdocs/) with following content:

    Code:
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php
    Source

    http://stackoverflow.com/questions/6...ebsite-address
    My website http://torfaenpcrepair.com/ which is in need of a revamp as it was started with the hosts WYSWYG and needs to be converted to a full CSS built site,

    I have made a start but still a way to go :)

  • Users who have thanked TPCR for this post:

    camzenxbt (03-24-2013)

  • #4
    Regular Coder
    Join Date
    Mar 2013
    Posts
    262
    Thanks
    4
    Thanked 67 Times in 67 Posts
    If you're using solely HTML/CSS, then you can do something like this in your cpanel.

    You have your directory. If you create a "example.html" file in your main directory, you can access it at

    http://www.cpsecure.x10.mx/example.html

    Well, how do you get rid of that stupid .html extension? Just create a folder. In your main directory, create a "example" folder. So, you have...

    /main_directory/example

    Then inside the example folder, put your index.html file there. On basically every server, the default page is the index file. It can be index.htm, index.html, index.php, etc.

    Whenever browsers try to access a folder, they basically look for the index file. Therefore, when you try to access the "example" folder, it'll automatically find the index.html file.

    Now, you can access the index file by simply going to: http://www.cpsecure.x10.mx/example/


  •  

    Tags for this Thread

    Posting Permissions

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