We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Admin panel works fine, main website 404s at all links!

How Do I?

Bitter-Pronunciation's avatar
Bitter-Pronunciation
9 posts
3 years ago
Bitter-Pronunciation's avatar Bitter-Pronunciation

Hey all -

I’ve got a website that we’re migrating to ExpressionEngine 6 from 2, and we’re having the strangest issue. The main page loads up okay, but all I get are 404s whenever I try to navigate to any other part of the website. We’re using the basic .htaccess file you mention here, and while that DOES remove the “index.php” from our URL, all of our links 404.

Then, if I move the contents of that .htaccess file into the actual Apache Httpd config file for the site (we have root access on our server), links seem to work, but CSS doesn’t load. I’m really not sure what’s happening (or where to find more verbose logs within the application itself) please help.

Server Specs:

Software Version
OS Alma Linux 8.6
Apache HTTPD 2.4.37
MariaDB 10.3.32
PHP 8.0.20

       
JCOGS Design's avatar
JCOGS Design
148 posts
3 years ago
JCOGS Design's avatar JCOGS Design

Might be worth checking if your base_url and base_path settings are correct.

When you update from EE2 sometimes it seems it is possible to arrive at EE6 and these values are not set, or are set incorrectly - which in turn can lead to unpredictable behaviour…

HTH

       
Bitter-Pronunciation's avatar
Bitter-Pronunciation
9 posts
3 years ago
Bitter-Pronunciation's avatar Bitter-Pronunciation

Yeah, those are set correctly. :/

       
peaston's avatar
peaston
14 posts
3 years ago
peaston's avatar peaston

check your htaccess file, when we migrated to 6 it caused some massive headaches

       
Bitter-Pronunciation's avatar
Bitter-Pronunciation
9 posts
3 years ago
Bitter-Pronunciation's avatar Bitter-Pronunciation

I guess I checked and, again, I’m just using the super basic one from the ExpressionEngine docs page I linked in my original post:

$ cat /var/www/html/example_com/.htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Removes index.php from ExpressionEngine URLs
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

    # Directs all EE web requests through the site index file
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

Our site is suuuuper basic, though - basically just a homepage with links to various product pages, about us, and a contact form. There’s no crazy extra functionality (aside from this little part number generator on one of the pages - but it isn’t even done yet and only lives on that one page!), so I don’t see why we’d need any of those extra steps from that .htaccess documentation. Add to that that that’s pretty much verbatim the same .htaccess file we had for our EE2 site, and… I’m at a bit of a loss. :(

       
peaston's avatar
peaston
14 posts
3 years ago
peaston's avatar peaston

yeah thats the same one i switched too….

       
Bitter-Pronunciation's avatar
Bitter-Pronunciation
9 posts
3 years ago
Bitter-Pronunciation's avatar Bitter-Pronunciation

Interestingly enough, when I go in and manually ADD index.php into the URI of the links that aren’t working, they all work fine.

Something about that .htaccess or some setting somewhere is not working. 😛

       
Bitter-Pronunciation's avatar
Bitter-Pronunciation
9 posts
3 years ago
Bitter-Pronunciation's avatar Bitter-Pronunciation

So, I figured it out! Turns out .htaccess files don’t actually have any effect on the way Apache serves up files without an AllowOverride directive in the site’s Apache config file. Since ExpressionEngine’s .htaccess file pretty much only makes use of Apache’s mod_rewrite module, you can tighten that AllowOverride directive to simply be AllowOverride FileInfo (as opposed to AllowOverride All, which might be a little too broad of a security posture and needlessly increase your site’s attack surface).

The AllowOverride directive cannot exist directly within the context of a VirtualHost directive, so it’s necessary to place it within a <Directory> directive nested within your ExpressionEngine site’s <VirtualHost> directive, like so:

<VirtualHost *:80>
  ServerName    staging.example.com
  ServerAlias   staging.example.com
  Redirect permanent / https://staging.example.com
</VirtualHost>

<VirtualHost *:443>
  ServerAdmin   [email protected]
  DocumentRoot  "/var/www/html/example_com"
  ServerName    staging.example.com
  ServerAlias   staging.example.com

  <Directory /var/www/html/example_com>
    AllowOverride FileInfo
  </Directory>

  CustomLog "/var/www/html/example_com/logs/httpd/example_com_access.log" common
  ErrorLog "/var/www/html/example_com/logs/httpd/example_com_error.log"

  SSLEngine on
  SSLCertificateFile    /etc/httpd/ssl/staging.example.com.crt
  SSLCertificateKeyFile /etc/httpd/ssl/staging.example.com.key
</VirtualHost>

Figured I’d be a good internet netizen and post my solution for the next poor soul who gets caught at this issue.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.