I'm new, first time I made a site... please help?

Discussion in 'Off Topic' started by vortex10, Sep 7, 2016.

  1. vortex10

    vortex10 New Member

    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    hi and good day,

    Sir, Ma'am

    How can I hide my index.html and all the pages with .html extensions?

    I spent 4 hours looking for a solution but until now nothing works. I added a .htaccess to the public and add this code

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^\.]+)$ $1.php [NC,L]
    RewriteRule ^([^\.]+)$ $1.html [NC,L]

    It still doesn't hide the index.html and .html extensions


    please help

    kind regards and Good day,
     
  2. jensen

    jensen Active Member

    Messages:
    1,164
    Likes Received:
    21
    Trophy Points:
    38
    not sure why one would hide the index.html as it's the first file the browsers look for?
    could you share why? keen to learn new stuff everyday.
     
  3. caftpx10

    caftpx10 Well-Known Member

    Messages:
    1,511
    Likes Received:
    112
    Trophy Points:
    63
    The web server would be the one looking for such files. By default, Apache's configuration is set to look out for index files such as 'index.html' (and 'index.php' after installation of PHP, they have priority and can be configured to be something other than having the 'index' prefix) in replacement of the index directory listing that it would fall back to.

    If you want to lie about the existence of '.html' files then you could throw out a 404 header along with setting a custom 404 page to use. If you go that way then I would also apply the same custom 404 to the entire site (if an actual file or directory doesn't exist) so that it better blends in.

    In regards to directory indexing, you might want to turn that off if you are trying to hide files.

    If what you are really looking for is to at least block access effectively to files with the '.html' file extension then you could go with the following in the '.htaccess file'..
    Code:
    <FilesMatch "/^(.*?)\.html/">
        Order Allow,Deny
        Deny from all
    </FilesMatch>
    This would throw out a 403 (forbidden).
    Note that I have not checked if the RegEx used is valid so you might have to try to figure that out.
     
    • Like Like x 1

Share This Page