0

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

1 Answer 1

1

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.

3
  • I see. I don't have any symlinks and the structure of the directory is pretty simple as well. Here is a snapshot: 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: share.getcloudapp.com/mXubkk56 Commented Feb 17, 2023 at 23:24
  • 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.
    – Joel R
    Commented Feb 17, 2023 at 23:44
  • 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 Commented Feb 18, 2023 at 0:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .