(I purposely titled it this way because the other suggestions I have seen in stackoverflow so far either do not apply in my case or do not work.)
I am in the process of moving a working Yii2 app from an Ubuntu 14.04 VM to a 22.04 VM, which I built separately instead of going through various OS upgrade steps to get to the current version. The PHP version is the same on both VMs. The pretty URL http://(server)/site/login returns a 404. The Apache2 access log shows:
192.168.130.212 - - [06/Mar/2023:18:30:03 -1000] "GET /site/login HTTP/1.1" 404 487 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/110.0"
192.168.130.212 - - [06/Mar/2023:18:30:03 -1000] "GET /favicon.ico HTTP/1.1" 200 1450 "http://beretania/site/login" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/110.0"
Nothing in the error log. I tried as much as possible to duplicate the server configuration. And the code itself, which is managed in GitHub, should be identical.
From config
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
.htaccess
# Requires FollowSymLinks to work; also turn on the REWRITE engine
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
</IfModule>
# Unless explicit file or director exists, redirect all requests to Yii entry script
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</IfModule>
AddType application/octet-stream .txt
The enabled site in both cases is called dbos.
Here is the dbos.conf
<VirtualHost *:80>
ServerAdmin jmdemoor@localhost
ServerName beretania
DocumentRoot /var/www/dbos/web
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/dbos/web/>
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Pertinent except from apache2.conf (which I assume is overridden by the enabled site dbos.conf anyway):
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
...
AccessFileName .htaccess
This is what I get:
The same url with the production VM works fine. Any ideas?
Thanks in advance.
Joe
Thank you to Michal Hynčica. mod_rewrite was not enabled.
$ sudo a2enmod rewrite
$ sudo systemctl restart apache2
Solved.