Why is my site consistently showing not found?

I recently connected migrated my website from Bluehost to a private server, and I am having trouble with the configuration of my apache server. No matter what page I attempt to visit on my site, it displays a 404 this url is not found on this server error.

My site is written in both perl and php. Mostly perl. Would a perl version mismatch between my old server and my new server make the not found error appear? I would think that would cause a 500 server error.

What am I doing wrong? What do I change in order to make it work?

I have played around with the part of my httpd.conf file that controls my website.

My site is behind a reverse proxy that points to my backend server running the site at 333.333.333.333/test

Here it is:

SuexecUserGroup "#1001" "#1001"
ServerName test.example.org
ServerAlias www.test.example.org
ServerAlias mail.test.example.org
ServerAlias webmail.test.example.org
ServerAlias admin.test.example.org
DocumentRoot /home/theuser/public_html/testrbs
ErrorLog /var/log/virtualmin/test.example.org_error_log
CustomLog /var/log/virtualmin/test.example.org_access_log combined
ScriptAlias /cgi-bin/ /home/theuser/public_html/test/cgi-bin
DirectoryIndex index.cgi index.html index.htm index.php index.php4 index.php5
<Directory "/home/theuser/public_html/test">
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch 
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
<Directory "/home/theuser/public_html/test/cgi-bin">
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>

The 404 error you’re experiencing likely indicates a misconfiguration in Apache, rather than a Perl version mismatch, which, as you guessed, would more likely result in a 500 error if Perl were causing issues. Here are a few possible causes and steps you can take to resolve the issue:

1. Check DocumentRoot Path

Ensure that the DocumentRoot path specified in your Apache configuration (/home/theuser/public_html/testrbs) matches the actual location of your site’s files on the new server. If the path differs, Apache will not find the files and return a 404 error.

Since your ScriptAlias and <Directory> blocks reference /home/theuser/public_html/test, confirm that:

  • The path /home/theuser/public_html/testrbs contains your website’s main files.
  • /home/theuser/public_html/test contains your CGI scripts or subdirectories, if applicable.

2. Verify Reverse Proxy Configuration

Since your site is behind a reverse proxy, make sure the proxy server is configured to forward requests correctly. For example, if the backend server is running on 333.333.333.333/test, confirm that the reverse proxy is pointing to this path.

In Apache, you might use directives like ProxyPass and ProxyPassReverse if it’s set up in this configuration. Ensure that the reverse proxy settings match the backend server’s URL structure.

Example reverse proxy configuration:

ProxyPass "/" "http://333.333.333.333/test/"
ProxyPassReverse "/" "http://333.333.333.333/test/"

3. Correct Directory and ScriptAlias Paths

Your configuration currently sets ScriptAlias and <Directory> paths to /home/theuser/public_html/test, but your DocumentRoot points to /home/theuser/public_html/testrbs. This discrepancy can confuse Apache.

Update the configuration to ensure consistent paths. For example, if all content is in testrbs, update your <Directory> and ScriptAlias paths accordingly:

DocumentRoot /home/theuser/public_html/testrbs
<Directory "/home/theuser/public_html/testrbs">
    Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch 
    AllowOverride All
    Require all granted
</Directory>

<Directory "/home/theuser/public_html/testrbs/cgi-bin">
    Options +ExecCGI
    Require all granted
</Directory>
ScriptAlias /cgi-bin/ /home/theuser/public_html/testrbs/cgi-bin/

4. Check File and Directory Permissions

Permissions issues can also cause 404 errors if Apache cannot read the files. Verify that:

  • The directory and its contents are readable by the Apache user (often www-data or apache).
  • Run chmod -R 755 /home/theuser/public_html/testrbs to set the appropriate permissions if necessary.

5. Enable CGI

Since your site uses Perl scripts, confirm that Apache is set to execute CGI scripts in the specified directory. Ensure you have the Options +ExecCGI directive in place for the /cgi-bin directory, as shown in the corrected configuration above.

6. Restart Apache

After making any changes, restart Apache to apply them:

sudo systemctl restart httpd

Finally

  • Ensure DocumentRoot points to the correct location.
  • Match Directory paths and ScriptAlias with the actual folder structure.
  • Configure Reverse Proxy settings to match your backend server.
  • Verify file permissions and enable CGI in the directory settings.