HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

About Error 404 Not Found

vrijvlindervrijvlinder Papillon-Sauvage MVP

Error 404 Not Found happens when the address to a file can't be found. This can be due to several factors. The first one you should look at is your .htaccess file.

The .htaccess (hypertext access) file is a directory-level configuration file supported by several web servers, that allows for decentralized management of web server configuration. They are placed inside the web tree, and are able to override a subset of the server's global configuration for the directory that they are in, and all sub-directories.

The .htaccess files can override many other configuration settings including content type and character set, CGI handlers, etc.

The .htaccess file is often used to specify security restrictions for a directory, hence the filename "access". The .htaccess file is often accompanied by a .htpasswd file which stores valid usernames and their passwords.

Servers often use .htaccess to rewrite long, overly comprehensive URLs to shorter and more memorable ones.

Use allow/deny to block users by IP address or domain. Also, use to block bad bots, rippers and referrers. Often used to restrict access by Search Engine spiders.

Control how the server will react when no specific web page is specified.

Changing the page that is shown when a server-side error occurs, for example HTTP 404 Not Found or, to indicate to a search engine that a page has moved, HTTP 301 Moved Permanently.

Instruct the server how to treat different varying file types.

The .htaccess files allow a server to control caching by web browsers and proxies to reduce bandwidth usage, server load, and perceived lag.

Most apps like Vanilla, contain an .htaccess file inside of the forum folder.

It looks much like this after being modified with the subdirectory name of the forum, If it is in the Root you would simply leave after the backslash empty /:

# Modified
# If you modify this file then change the above line to: # Modified
<IfModule mod_rewrite.c>
   RewriteEngine On
   # Certain hosts may require the following line.
   # If vanilla is in a subfolder then you need to specify it after the /. 
   # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
   RewriteBase /thenameofmysubdirectory
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]
</IfModule>

This is what it looks like for Root install

# Modified
# If you modify this file then change the above line to: # Modified
<IfModule mod_rewrite.c>
   RewriteEngine On
   # Certain hosts may require the following line.
   # If vanilla is in a subfolder then you need to specify it after the /. 
   # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]
</IfModule>

If after fixing your .htaccess file you still get 404 not found errors, you will need to check the links and see if they are pointing in the correct path.

Sometimes it is necessary to put in the full path to an image or file. A simple mistake like a typo in the link can also cause a not found error.

Tagged:

Comments

  • hgtonighthgtonight ∞ · New Moderator

    In my opinion, the absolute first step in diagnosing a 404 error is to ensure the URL is correctly formed. This goes double if you typed the address in by hand.

    Good information!

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    The configuration to add inside the config.php

    $Configuration['Garden']['RewriteUrls'] = TRUE;

  • Checked the htaccess file and there are no errors or omissions. I also added the line of code to the config file like was suggested.

    I still get the same problem.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    @goozleology said:
    Checked the htaccess file and there are no errors or omissions. I also added the line of code to the config file like was suggested.

    I still get the same problem.

    You did not check the access file as I explained in this tutorial, you skimmed the information and it turns out that was your problem.

  • noncenonce Necro-on Forensics
    edited March 2016

    apache specific perhaps

    In my opinion the first thing to determine is what type of webserver you are using and does your web server even read the .htaccess file.

    Questions to ask yourself prior to the above.

    First Question - what type of server are you using and what is your setup.
    are you using apache?

    if the Answer is apache - read the above. If not, you might be better to chase a different goose relating to IIS or nginx or what else.

    Second question: are you actually re-writing the url? (vanilla has a few bugs if url is not re-written.)
    once you have added the url and the proper config statement for rewriting url.

    Does nginx or IIS even use .htaccess (google it).

  • pitymaiapitymaia New
    edited September 2016

    I Have the same issue here.
    I'm using Apache2, have the .htaccess like the above and turn on the flag $Configuration['Garden']['RewriteUrls'] = TRUE;
    This result in 404 Not Found.
    I also tryed clear the cache folder, but nothing works.

    Maybe the problem is that when install I missed the .htaccess and coment an if on class.setupcontroller to install Vanilla:
    if (!file_exists(PATH_ROOT.'/.htaccess') && !$this->Form->getFormValue('SkipHtaccess')) {
    (...)

    But I uncommented this.
    Tell me I don't need to re-install the Vanilla to get friendly URLs... Any help?

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    It is very simple if you follow directions.

    Post your htaccess file here so we can determine if it is your error or a bug.

    As to the configuration , re read this:

    https://vanillaforums.org/discussion/comment/204192/#Comment_204192

  • pitymaiapitymaia New
    edited September 2016

    My file "config.php" have this:
    $Configuration['Garden']['RewriteUrls'] = TRUE;

    my file "config-defaults.php" also have this:
    $Configuration['Garden']['RewriteUrls'] = TRUE;

    This is my .htaccess:

     # Modified
     # If you modify this file then change the above line to: # Modified
    <IfModule mod_rewrite.c>
       RewriteEngine On
       # Certain hosts may require the following line.
       # If vanilla is in a subfolder then you need to specify it after the /.
       # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
       RewriteBase /
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]
    </IfModule>
    

    I also tryed the original file with the comand " RewriteBase /" commented like this
    # RewriteBase /

    The result are always the same, an error 404 Not Found.

    But as I say, I have install the Vanilla with a modification on the file "class.setupcontroller.php"
    I commentde this lines:

     // Make sure the user has copied the htaccess file over.
     //if (!file_exists(PATH_ROOT.'/.htaccess') && !$this->Form->getFormValue('SkipHtaccess')) {
          //$this->setData('NoHtaccess', true);
          // $this->Form->addError(t('You are missing Vanilla\'s .htaccess file.', 'You are missing Vanilla\'s <b>.htaccess</b> file. Sometimes this file isn\'t copied if you are using ftp to upload your files because this file is hidden. Make sure you\'ve copied the <b>.htaccess</b> file before continuing.'));
     //}
    

    I undo this modification now, but this dont fix my problem.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited September 2016

    But as I say, I have install the Vanilla with a modification on the file "class.setupcontroller.php"
    I commentde this lines:

    WHY??

    I also tryed the original file with the comand " RewriteBase /" commented like this
    # RewriteBase /

    The # disables the rewrite rule.

    What IS your forum URL ??? Avoid modifying things that you do not understand what they do.. modifying core files without knowing what you are doing voids the software warranty... :P

  • pitymaiapitymaia New
    edited September 2016

    @vrijvlinder said:

    But as I say, I have install the Vanilla with a modification on the file "class.setupcontroller.php"
    I commentde this lines:

    WHY??

    I made a mistake. I'm in the rush to puting the forum online fast and when the forum ask for the .htaccess I don't learn about it, I just find a bad recomendation on stakoverflow and use it.

    What IS your forum URL ??? Avoid modifying things that you do not understand what they do.. modifying core files without knowing what you are doing voids the software warranty... :P

    This is my forum, click in any topic and you see the problem: religiaoeveneno.com.br/

  • @pitymaia, is your web hosting a VPS or dedicated server? Make sure that the mod_rewrite module is enabled.

    Add Pages to Vanilla with the Basic Pages app

  • @Shadowdare said:
    @pitymaia, is your web hosting a VPS or dedicated server? Make sure that the mod_rewrite module is enabled.

    I'm using a VPS linode: https://linode.com/pricing
    The cheapest one.
    I will look in this link you post.

  • @Shadowdare My PHP info do not shows mod_rewrite enabled. I will get more info about and follow the link.

  • @Shadowdare , This solve the problem on my localhost. You give-me the missing information. Thank you both for your time and knowledge. :)

  • RiverRiver MVP
    edited September 2016

    @pitymaia said:
    My file "config.php" have this:
    $Configuration['Garden']['RewriteUrls'] = TRUE;

    my file "config-defaults.php" also have this:
    $Configuration['Garden']['RewriteUrls'] = TRUE;

    don't change the config-defaults.php - ONLY change config.php , it will override the defaults.

    Bad idea.

    see the part

    https://github.com/vanilla/vanilla/blob/master/conf/config-defaults.php#L2

    also you may want to see this as well for apache related info if people still don't understand.

    https://vanillaforums.org/discussion/comment/220157/#Comment_220157

    https://vanillaforums.org/discussion/comment/243043/#Comment_243043

    https://vanillaforums.org/discussion/comment/242007/#Comment_242007

    if you have access to command line a2query - a2query -m - check for rewrite rules
    or use phpinfo to check for modules.

    IIS related

    http://www.iis.net/downloads/microsoft/url-rewrite

    https://vanillaforums.org/discussion/27568/enabling-clean-urls-on-iis-installations

    Nginx related

    https://vanillaforums.org/discussion/30390/cant-access-categories-nginx-nice-urls

    https://vanillaforums.org/discussion/comment/227015#Comment_227015

    http://docs.vanillaforums.com/developer/backend/

    and the other questions.

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • Thanks for the links and info @River I'm a Python guy and need install a forum realy fast. But now I have more time to learn about it and made a better configuration. This links will help.

  • I am having the same issue here. I am wondering if there's an interaction with the WordPress .htaccess file; I have Wordpress as the primary site interface but was hoping to add a Vanilla forum, which IMHO has the best interface today, in a subdirectory. I uploaded the files, set the permissions, and went to the domain/talk, which redirects to the nonexistent directory domain/talk/dashboard/setup — which 404s. I have all the php and MySQL prereqs, double-checked; the system did not create an .htaccess or config file so I created the .haccess myself using the default one. It does not have an effect so far.

    I added the rewrite base... any other thoughts? Should I move config.php out? (I tried this as well). I tried retyping the URL a few times to make sure. Changed permissions variously “just in case.” No error messages that I can see.

    It's Apache 2.x (the current update, can't recall the number), php 7.2, CentOS under CPanel. Thanks in advance.

        # Modified
        # If you modify this file then change the above line to: # Modified
    
        <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteBase /talk
            DirectoryIndex disabled
    
            ####
            # Deny access to certain directories that SHOULD NOT be exposed.
            ####
            RewriteRule (^|/)\.git - [L,R=403]
            RewriteRule ^cache/ - [L,R=403]
            RewriteRule ^cgi-bin/ - [L,R=403]
            RewriteRule ^uploads/import/ - [L,R=403]
            RewriteRule ^vendor/ - [L,R=403]
    
          ####
            RewriteCond %{REQUEST_URI} !/index.php$
            RewriteRule (.+\.php) [E=X_REWRITE:1,E=X_PATH_INFO:/$1,L]
    
            ####
            # Redirect any non existing file/directory to /index.php
            ####
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule (.*) index.php [E=X_REWRITE:1,E=X_PATH_INFO:/$1,L]
    
            ####
            # Add the proper X_REWRITE server variable for rewritten requests.
            ####
            RewriteCond %{ENV:REDIRECT_X_REWRITE} .+
            RewriteCond %{ENV:REDIRECT_X_PATH_INFO} (.+)
            RewriteRule ^index\.php - [E=X_REWRITE:1,E=!REDIRECT_X_REWRITE,E=X_PATH_IN$
        </IfModule>
    
        <IfModule mod_headers.c>
           <FilesMatch "(?<!embed)\.(css|js|woff|ttf|eot|svg|png|gif|jpeg|jpg|ico|swf)$
              Header set Cache-Control "max-age=315360000"
              Header set Expires "31 December 2037 23:59:59 GMT"
           </FilesMatch>
        </IfModule>
    
  • @Postpar said:
    Should I move config.php out?

    Hello, if the system is looking for dashboard/setup, it shouldn't have a config.php file yet. Did you manually create one?

  • Never mind. I signed in today and — the problem is gone. Cache issue? Who knows?

  • (To answer your question, I tried with and without manually creating one.)

Sign In or Register to comment.