Mod_rewrite is enabled but index.php still exists in web address

I have mod_rewrite enabled by default but when I add the proper config variables, index.php still appears in the address for my NC installation which I have it installed on a subdomain. Here is the latest error from the logs.

Nextcloud version (eg, 20.0.5): 24.0.6
Operating system and version (eg, Ubuntu 20.04): CentOS 8
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.53
PHP version (eg, 7.4): 8.0.19

The issue you are facing:

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Enabled mod_rewrite
  2. Add htaccess.RewriteBase and overwrite.cli.url to config.php file
  3. Save and upload config.php file
  4. Refresh or click a link

The output of your Nextcloud log in Admin > Logging:

Error: foreach() argument must be of type array|object, bool given at /home/admin/domains/serenitydev.xyz/public_html/nebula/apps/serverinfo/lib/OperatingSystems/DefaultOs.php#147
/home/admin/domains/serenitydev.xyz/public_html/nebula/apps/serverinfo/lib/OperatingSystems/DefaultOs.php - line 147:

OC\Log\ErrorHandler::onError()

/home/admin/domains/serenitydev.xyz/public_html/nebula/apps/serverinfo/lib/Os.php - line 109:

OCA\ServerInfo\OperatingSystems\DefaultOs->getNetworkInterfaces()

/home/admin/domains/serenitydev.xyz/public_html/nebula/apps/serverinfo/lib/Settings/AdminSettings.php - line 81:

OCA\ServerInfo\Os->getNetworkInterfaces()

/home/admin/domains/serenitydev.xyz/public_html/nebula/apps/settings/lib/Controller/CommonSettingsTrait.php - line 129:

OCA\ServerInfo\Settings\AdminSettings->getForm()

/home/admin/domains/serenitydev.xyz/public_html/nebula/apps/settings/lib/Controller/AdminSettingsController.php - line 83:

OCA\Settings\Controller\AdminSettingsController->formatSettings()

/home/admin/domains/serenitydev.xyz/public_html/nebula/apps/settings/lib/Controller/CommonSettingsTrait.php - line 140:

OCA\Settings\Controller\AdminSettingsController->getSettings()

/home/admin/domains/serenitydev.xyz/public_html/nebula/apps/settings/lib/Controller/AdminSettingsController.php - line 68:

OCA\Settings\Controller\AdminSettingsController->getIndexResponse()

/home/admin/domains/serenitydev.xyz/public_html/nebula/lib/private/AppFramework/Http/Dispatcher.php - line 225:

OCA\Settings\Controller\AdminSettingsController->index()

/home/admin/domains/serenitydev.xyz/public_html/nebula/lib/private/AppFramework/Http/Dispatcher.php - line 133:

OC\AppFramework\Http\Dispatcher->executeController()

/home/admin/domains/serenitydev.xyz/public_html/nebula/lib/private/AppFramework/App.php - line 172:

OC\AppFramework\Http\Dispatcher->dispatch()

/home/admin/domains/serenitydev.xyz/public_html/nebula/lib/private/Route/Router.php - line 298:

OC\AppFramework\App::main()

/home/admin/domains/serenitydev.xyz/public_html/nebula/lib/base.php - line 1030:

OC\Route\Router->match()

/home/admin/domains/serenitydev.xyz/public_html/nebula/index.php - line 36:

OC::handleRequest()

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => '**********',
  'passwordsalt' => '************************',
  'secret' => '**************************',
  'trusted_domains' => 
  array (
    0 => 'nebula.serenitydev.xyz',
  ),
  'datadirectory' => '/home/admin/domains/serenitydev.xyz/public_html/nebula/data',
  'dbtype' => 'mysql',
  'version' => '24.0.6.1',
  'overwrite.cli.url' => 'https://nebula.serenitydev.xyz',
  'dbname' => '************',
  'dbhost' => 'localhost',
  'dbport' => '3306',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '************',
  'dbpassword' => '*************',
  'installed' => true,
  'overwrite.cli.url' => 'https://nebula.serenitydev.xyz/',
  'htaccess.RewriteBase' => '/',
  'default_phone_region' => 'US',
);

The output of your Apache/nginx/system log in /var/log/____:

[Sun Oct 16 00:10:42.952805 2022] [mpm_event:notice] [pid 37935:tid 139797319293248] AH00493: SIGUSR1 received.  Doing graceful restart
AH00112: Warning: DocumentRoot [/home/admin/domains/serenitydev.xyz/public_html/alpha] does not exist
AH00112: Warning: DocumentRoot [/home/admin/domains/serenitydev.xyz/private_html/alpha] does not exist
[Sun Oct 16 00:10:43.092920 2022] [ssl:warn] [pid 37935:tid 139797319293248] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sun Oct 16 00:10:43.093904 2022] [ssl:warn] [pid 37935:tid 139797319293248] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Oct 16 00:10:43.094683 2022] [lbmethod_heartbeat:notice] [pid 37935:tid 139797319293248] AH02282: No slotmem from mod_heartmonitor
[Sun Oct 16 00:10:43.094895 2022] [mpm_event:notice] [pid 37935:tid 139797319293248] AH00489: Apache/2.4.53 (Unix) OpenSSL/1.1.1k configured -- resuming normal operations
[Sun Oct 16 00:10:43.094912 2022] [core:notice] [pid 37935:tid 139797319293248] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun Oct 16 00:11:42.764078 2022] [mpm_event:notice] [pid 37935:tid 139797319293248] AH00493: SIGUSR1 received.  Doing graceful restart
AH00112: Warning: DocumentRoot [/home/admin/domains/serenitydev.xyz/public_html/alpha] does not exist
AH00112: Warning: DocumentRoot [/home/admin/domains/serenitydev.xyz/private_html/alpha] does not exist
[Sun Oct 16 00:11:42.796983 2022] [ssl:warn] [pid 37935:tid 139797319293248] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sun Oct 16 00:11:42.797687 2022] [ssl:warn] [pid 37935:tid 139797319293248] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Oct 16 00:11:42.798049 2022] [lbmethod_heartbeat:notice] [pid 37935:tid 139797319293248] AH02282: No slotmem from mod_heartmonitor
[Sun Oct 16 00:11:42.798249 2022] [mpm_event:notice] [pid 37935:tid 139797319293248] AH00489: Apache/2.4.53 (Unix) OpenSSL/1.1.1k configured -- resuming normal operations
[Sun Oct 16 00:11:42.798259 2022] [core:notice] [pid 37935:tid 139797319293248] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun Oct 16 00:49:56.708667 2022] [authz_core:error] [pid 151133:tid 139796126942976] [client 159.89.239.57:56908] AH01630: client denied by server configuration: /var/www/html/.env
[Sun Oct 16 01:28:52.240577 2022] [authz_core:error] [pid 151133:tid 139796513007360] [client 103.156.91.37:61617] AH01630: client denied by server configuration: /var/www/html/.env
[Sun Oct 16 00:49:56.708667 2022] [authz_core:error] [pid 151133:tid 139796126942976] [client 159.89.239.57:56908] AH01630: client denied by server configuration: /var/www/html/.env
[Sun Oct 16 01:28:52.240577 2022] [authz_core:error] [pid 151133:tid 139796513007360] [client 103.156.91.37:61617] AH01630: client denied by server configuration: /var/www/html/.env
[Sun Oct 16 01:28:56.366891 2022] [authz_core:error] [pid 151133:tid 139796479436544] [client 103.156.91.37:61807] AH01630: client denied by server configuration: /var/www/html/.env
[Sun Oct 16 03:37:40.694494 2022] [mpm_event:notice] [pid 37935:tid 139797319293248] AH00493: SIGUSR1 received.  Doing graceful restart
AH00112: Warning: DocumentRoot [/home/admin/domains/serenitydev.xyz/public_html/alpha] does not exist
AH00112: Warning: DocumentRoot [/home/admin/domains/serenitydev.xyz/private_html/alpha] does not exist

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

{"reqId":"Y0t5XmfvfYxPWM4Bxpt0mwAAywA","level":2,"time":"2022-10-16T03:24:14+00:00","remoteAddr":"162.249.230.56","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not detect any host in https:///data/htacc$
{"reqId":"Y0t5XmfvfYxPWM4Bxpt0mwAAywA","level":2,"time":"2022-10-16T03:24:14+00:00","remoteAddr":"162.249.230.56","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not detect any host in http:///data/htacce$
{"reqId":"Y0t84_LMxuqYdFCq0edSywABUwA","level":2,"time":"2022-10-16T03:39:15+00:00","remoteAddr":"162.249.230.56","user":"--","app":"no app in context","method":"GET","url":"/index.php/csrftoken","message":"Could not detect any host in $
{"reqId":"Y0t84_LMxuqYdFCq0edSywABUwA","level":2,"time":"2022-10-16T03:39:15+00:00","remoteAddr":"162.249.230.56","user":"--","app":"no app in context","method":"GET","url":"/index.php/csrftoken","message":"Could not detect any host in $
{"reqId":"Y0uAZ8PNEj7SdS4oQyTSmwAAUwA","level":2,"time":"2022-10-16T03:54:16+00:00","remoteAddr":"162.249.230.56","user":"--","app":"no app in context","method":"GET","url":"/index.php/csrftoken","message":"Could not detect any host in $
{"reqId":"Y0uAZ8PNEj7SdS4oQyTSmwAAUwA","level":2,"time":"2022-10-16T03:54:16+00:00","remoteAddr":"162.249.230.56","user":"--","app":"no app in context","method":"GET","url":"/index.php/csrftoken","message":"Could not detect any host in $
{"reqId":"Y0uD68PNEj7SdS4oQyTSoQAAYgA","level":2,"time":"2022-10-16T04:09:15+00:00","remoteAddr":"162.249.230.56","user":"--","app":"no app in context","method":"GET","url":"/index.php/csrftoken","message":"Could not detect any host in $
{"reqId":"Y0uD68PNEj7SdS4oQyTSoQAAYgA","level":2,"time":"2022-10-16T04:09:15+00:00","remoteAddr":"162.249.230.56","user":"--","app":"no app in context","method":"GET","url":"/index.php/csrftoken","message":"Could not detect any host in $
{"reqId":"Y0uHb8PNEj7SdS4oQyTSpwAAcAA","level":2,"time":"2022-10-16T04:24:15+00:00","remoteAddr":"162.249.230.56","user":"--","app":"no app in context","method":"GET","url":"/index.php/csrftoken","message":"Could not detect any host in $
{"reqId":"Y0uHb8PNEj7SdS4oQyTSpwAAcAA","level":2,"time":"2022-10-16T04:24:15+00:00","remoteAddr":"162.249.230.56","user":"--","app":"no app in context","method":"GET","url":"/index.php/csrftoken","message":"Could not detect any host in $
{"reqId":"Y0uK98PNEj7SdS4oQyTStAAATgA","level":2,"time":"2022-10-16T04:39:19+00:00","remoteAddr":"162.249.230.56","user":"--","app":"no app in context","method":"GET","url":"/index.php/csrftoken","message":"Could not detect any host in $
{"reqId":"Y0uK98PNEj7SdS4oQyTStAAATgA","level":2,"time":"2022-10-16T04:39:19+00:00","remoteAddr":"162.249.230.56","user":"--","app":"no app in context","method":"GET","url":"/index.php/csrftoken","message":"Could not detect any host in $
{"reqId":"Y0uLfsPNEj7SdS4oQyTStgAAVAA","level":2,"time":"2022-10-16T04:41:34+00:00","remoteAddr":"162.249.230.56","user":"--","app":"no app in context","method":"POST","url":"/index.php","message":"Could not detect any host in https:///$
{"reqId":"Y0uLfsPNEj7SdS4oQyTStgAAVAA","level":2,"time":"2022-10-16T04:41:34+00:00","remoteAddr":"162.249.230.56","user":"--","app":"no app in context","method":"POST","url":"/index.php","message":"Could not detect any host in http:///d$
{"reqId":"Y0uNXcPNEj7SdS4oQyTTggAAAFE","level":3,"time":"2022-10-16T04:49:34+00:00","remoteAddr":"162.249.230.56","user":"Cupara","app":"no app in context","method":"POST","url":"/index.php/settings/apps/enable","message":"Table \"oc_up$
{"reqId":"Y0uNXcPNEj7SdS4oQyTTggAAAFE","level":3,"time":"2022-10-16T04:49:34+00:00","remoteAddr":"162.249.230.56","user":"Cupara","app":"no app in context","method":"POST","url":"/index.php/settings/apps/enable","message":"Table \"oc_up$
{"reqId":"Y0uNXcPNEj7SdS4oQyTTggAAAFE","level":3,"time":"2022-10-16T04:49:34+00:00","remoteAddr":"162.249.230.56","user":"Cupara","app":"no app in context","method":"POST","url":"/index.php/settings/apps/enable","message":"Table \"oc_up$
{"reqId":"Y0uOG8PNEj7SdS4oQyTT1AAAAGs","level":3,"time":"2022-10-16T04:52:45+00:00","remoteAddr":"162.249.230.56","user":"Cupara","app":"settings","method":"POST","url":"/index.php/settings/apps/enable","message":"could not enable apps"$
{"reqId":"Y0uOVMPNEj7SdS4oQyTUFgAAewI","level":3,"time":"2022-10-16T04:53:42+00:00","remoteAddr":"162.249.230.56","user":"Cupara","app":"no app in context","method":"POST","url":"/index.php/settings/apps/enable","message":"Table \"oc_so$
{"reqId":"Y0uQgsPNEj7SdS4oQyTVbgAAUwQ","level":3,"time":"2022-10-16T05:03:00+00:00","remoteAddr":"162.249.230.56","user":"Cupara","app":"PHP","method":"PUT","url":"/ocs/v2.php/cloud/users/Cupara","message":"getimagesizefromstring(): Err$
{"reqId":"Y0uQgsPNEj7SdS4oQyTVbQAAUwY","level":3,"time":"2022-10-16T05:03:00+00:00","remoteAddr":"162.249.230.56","user":"Cupara","app":"no app in context","method":"PUT","url":"/ocs/v2.php/cloud/users/Cupara","message":"VCard object wi$
{"reqId":"Y0uQgsPNEj7SdS4oQyTVbAAAUwM","level":3,"time":"2022-10-16T05:03:00+00:00","remoteAddr":"162.249.230.56","user":"Cupara","app":"no app in context","method":"PUT","url":"/ocs/v2.php/cloud/users/Cupara","message":"VCard object wi$
{"reqId":"Y0uQpsPNEj7SdS4oQyTVdgAAcgM","level":3,"time":"2022-10-16T05:03:35+00:00","remoteAddr":"162.249.230.56","user":"Cupara","app":"no app in context","method":"PUT","url":"/index.php/settings/users/Cupara/settings","message":"Expe$
{"reqId":"Y1Mxi1yi2FD0HIMldq0ohgAAAUg","level":3,"time":"2022-10-21T23:55:55+00:00","remoteAddr":"162.249.230.56","user":"Cupara","app":"PHP","method":"GET","url":"/index.php/settings/admin/serverinfo","message":"foreach() argument must$

I found my answer in this topic: https://help.nextcloud.com/t/howto-get-rid-of-index-php-in-nextcloud-path-shorter-url/74632

Sorry if I wasted anyone time.