Score:0

Getting 404 on a specific path /pricing with Apache server

bq flag

I've set up an Apache server on Ubuntu 20.04

The site loads fine when I load the home page first (https://leadzilla.ai) and after that when I click on the pricing button and it takes me to https://leadzilla.ai/pricing and the that page loads fine as well.

But when I go directly to https://leadzilla.ai/pricing in the browser, I get a 404

Here is what I have in /etc/apache2/sites-available/leadzilla.ai.conf

<VirtualHost *:80>
    DocumentRoot /var/www/leadzilla.ai
    ServerName leadzilla.ai
    ServerAlias www.leadzilla.ai

    <Directory /var/www/leadzilla.ai>
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Allow from all
    </Directory>

RewriteEngine on
RewriteCond %{SERVER_NAME} =leadzilla.ai [OR]
RewriteCond %{SERVER_NAME} =www.leadzilla.ai
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

I have this config in /etc/apache2/sites-available/leadzilla.ai-le-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
    DocumentRoot /var/www/leadzilla.ai
    ServerName leadzilla.ai
    ServerAlias www.leadzilla.ai

    <Directory /var/www/leadzilla.ai>
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Allow from all
        #Deny from all
        #Allow from 127.0.0.1
        #Allow from ::1
    </Directory>
    <Directory /var/www/leadzilla.ai/blog>
        AllowOverride All
    </Directory>

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/leadzilla.ai/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/leadzilla.ai/privkey.pem
</VirtualHost>
</IfModule>

I have Wordpress on https://leadzilla.ai/blog so that has to be taken care of as well.

Here is what I have tried: RewriteRule ^pricing$ pricing.html [NC]

I added it before the other rewrite rule but that doesn't seem to be working. Any ideas?

[EDIT]

This is solved now. The issue was a Next.js config, not an Apache config.

I put in exportTrailingSlash: true in my module.exports and it worked

Score:1
jp flag

I find this to be curious behavior. But if you have a RewriteRule in the <VirtualHost *:443>, then you should also have RewriteEngine On.

Are there any symbolic links in your directory at all. Anything like foo -> foo.html?

Are there any directories like /var/www/html/pricing/ in your directory structure?

Also, remember, that all of your traffic ends up on HTTPS, which means that only the <VirtualHost *:443> is in play. The other virtual host entry only is used long enough to redirect from HTTP to HTTPS. Any rewrite rules for the :80 VirtualHost do not apply on HTTPS.

Saurav Gupta avatar
bq flag
I see. I don't have any symlinks and the structure of the directory is pretty simple as well. Here is a snapshot: https://share.getcloudapp.com/GGuJOORo Could the issue be due to WordPress? I have Wordpress in the `blog` folder and in the picture above and the .htaccess looks like this: https://share.getcloudapp.com/mXubkk56
Joel R avatar
jp flag
Wordpress isn't the issue. There's something else going on here. You're using some sort of web framework or web application, something that I am unfamiliar with. When I click from the homepage to one of your subpages, it works, but I don't see the usual HTTP traffic. My guess is you are using Next.js (?) which means you should look to its configuration if you are indeed using it.
Saurav Gupta avatar
bq flag
Yes I am using Next.js but I've run `npm run build` and exported static index.html, CSS and JS files in a directory and put in on the server. I'll take a stab at next.js configuration with Apache
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.