1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Best way to manage html pages for server

Discussion in 'HTML & Website Design' started by Rare Pepe, Aug 21, 2016.

  1. #1
    Hello everyone,

    I have a website where all my html pages are stored inside of "html" folder. Everything is nice and sound until I have to navigate to that page.

    For example, I have a page inside of "html" folder called register.html and the only way to access it is by going through example.com/html/register.html.

    Instead, I want to access that page through example.com/register.html, but it returns me an error 404 (file not found)

    Any ideas how can this be achieved?
    SEMrush
    Thanks,

    Pepe
     
    Rare Pepe, Aug 21, 2016 IP
    SEMrush
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,005
    Likes Received:
    4,348
    Best Answers:
    123
    Trophy Points:
    665
    #2
    use your .htaccess to rewrite the urls
    but why not just move the files?
     
    sarahk, Aug 21, 2016 IP
  3. Shahidul Islam

    Shahidul Islam Active Member

    Messages:
    42
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    68
    #3
    You should edit .htaccess to overwrite your current url.
    But if you don't know about apace server to edit .htaccess, you move register.html file from folder to root
     
    Shahidul Islam, Aug 21, 2016 IP
  4. Puntocom81

    Puntocom81 Banned

    Messages:
    80
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    35
    #4
    Why don't you store the html pages under / instead of /html ? I'd copy them to / recursively, then create 301 redirects and remove the directory html.

    Backup first to be prepared in case of error:
    
    $ tar -cvf ~/project.tar
    
    Code (markup):
    
    $ cp -r html/* .
    $ rm -rf html
    
    Code (markup):
     
    Puntocom81, Aug 22, 2016 IP
  5. Rare Pepe

    Rare Pepe Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    I have a lot of .html pages and storing them in the root folder would create clutter on my server.
     
    Rare Pepe, Aug 22, 2016 IP
  6. Puntocom81

    Puntocom81 Banned

    Messages:
    80
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    35
    #6
    Do you use virtualhosts? each domain/hostname you are hosting should have a directory.
     
    Puntocom81, Aug 22, 2016 IP
  7. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #7
    If I understand you correctly, you have all your *.html files within html/ folder - while other files are situated in the root of the server, and perhaps even files in other folders? It sounds to me like you need to rethink your organisation, but if that's not an option, just use .htaccess to rewrite the shown url?

    Something like:
    RewriteRule ^(.*)$ /html/$1 (although you'll probably want to make sure this only applies to html-files, and perhaps even make some other changes so that you can use pretty urls (example.com/register instead of example.com/register.html or example.com/html/register.html)
     
    PoPSiCLe, Aug 22, 2016 IP
  8. Rare Pepe

    Rare Pepe Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #8
    I am surprised this is not a common technique of storing .html files in a separate folder. I am now questioning whether or not I should do it.

    So all major websites such are storing their .html files in a root folder? Is this how most web developers organize their files?
     
    Rare Pepe, Aug 23, 2016 IP
  9. Puntocom81

    Puntocom81 Banned

    Messages:
    80
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    35
    #9
    Why do you want to do that? if the site is purely static, the normal scheme is an index.html for the root directory and one index.html per extra directory/section of the web. index.html is, by default, the file to load by the web server.

    Mayor websites are dynamic, normally PHP; in this case a good approach is to route all requests through index.php located at root directory. This may interest you: https://forums.digitalpoint.com/threads/looking-for-foundation-6-advice-help.2780777/#post-19341840
     
    Puntocom81, Aug 23, 2016 IP
    sarahk likes this.
  10. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #10
    Yeah, I wonder a bit myself. Depending on what you want to do, storing the base files (either .html or .php in the root folder of the domain is normal). As @Puntocom81 says, this is common for almost every site on the web.

    Personally, I have my php-files in the root (most of them, at least), and common files for specific subsections in subfolders - like "reports" and similar. I also run all script files and css-files and such in subfolders, although this might vary a bit from dev to dev.
     
    PoPSiCLe, Aug 23, 2016 IP
  11. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,647
    Likes Received:
    1,976
    Best Answers:
    250
    Trophy Points:
    515
    #11
    Think on this, what makes storing it in /var/web/sitename/www/html ANY different than /var/web/sitename/www/ ? What do you have in the root other than directories and maybe one or two config files that makes it "create clutter"?!?

    Generally I try to organize my files so that all links are "down tree" -- which means user callable markup goes in the root, or through a single unified index.php via a rewriterule.

    For example:

    / -- root, all user callable content markup and/or server code

    /downloads -- user downloads

    /images -- content images

    /includes -- included sub-files

    /libs -- .php library files

    /scripts -- .js includes

    /template/templatename/ -- template files (common.template.php, screen.css, etc)

    /template/templatename/images -- presentational images loaded by the CSS, since if the CSS file is in template/templatename a url(images/h1Logo.png) in the .css file would resolve as template/templatename/images/h1Logo.png. Remember that, CSS resolves relative to the CSS file location!

    That way all links from the HTML point down-tree instead of resorting to the fragile "../" up-tree nonsense.

    Though again, once you have enough files that it becomes "too much" to have in the root, it's probably WAY past time to put on the big boy pants and get some server-side code like PHP or ASP.NET to help to manage that. In doing so I like to use the "one index to rule them all" so that a single index.php loads the common elements of all pages (header, menu, footer) and then includes just the unique content from a subdirectory.

    You don't need a full blown CMS to do that either if you prefer retaining control over the bulk of your markup.
     
    deathshadow, Aug 23, 2016 IP