diff --git a/.gitignore b/.gitignore
index c96bb6c371fa..e82f5252fbc4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -60,9 +60,6 @@ writable/session/*
writable/uploads/*
!writable/uploads/index.html
-writable/data/*
-!writable/data/index.html
-
writable/debugbar/*
php_errors.log
diff --git a/data/.htaccess b/data/.htaccess
new file mode 100644
index 000000000000..f24db0accc73
--- /dev/null
+++ b/data/.htaccess
@@ -0,0 +1,6 @@
+
+ Require all denied
+
+
+ Deny from all
+
diff --git a/system/Database/SQLite3/Connection.php b/system/Database/SQLite3/Connection.php
index 5cef2243ad76..2053f270160c 100644
--- a/system/Database/SQLite3/Connection.php
+++ b/system/Database/SQLite3/Connection.php
@@ -85,10 +85,13 @@ public function connect(bool $persistent = false)
}
try
{
+ $dataPath = ROOTPATH . 'data';
+ ! is_dir($dataPath) && mkdir($dataPath, 0777, true);
+
$this->database = ($this->database === ':memory:')
? $this->database
: (strpos($this->database, DIRECTORY_SEPARATOR) === false
- ? WRITEPATH . 'data' . DIRECTORY_SEPARATOR . $this->database
+ ? $dataPath . DIRECTORY_SEPARATOR . $this->database
: $this->database);
return (! $this->password)
diff --git a/user_guide_src/source/changelogs/v4.0.4.rst b/user_guide_src/source/changelogs/v4.0.4.rst
index c7598516b684..f96693ce48bd 100644
--- a/user_guide_src/source/changelogs/v4.0.4.rst
+++ b/user_guide_src/source/changelogs/v4.0.4.rst
@@ -5,11 +5,11 @@ Release Date: Unreleased
**4.0.4 release of CodeIgniter4**
-The location for the SQLite3 database has changed and by default will be now located in a ``writable/data`` folder instead of the ``public`` folder.
+The location for the SQLite3 database has changed and by default will be now located in a ``./data`` folder instead of the ``public`` folder.
Enhancements:
Bugs Fixed:
-- Fixed location for the SQLite3 database which by default will be now located in a ``writable/data`` folder instead of the ``public`` folder.
+- Fixed location for the SQLite3 database which by default will be now located in a ``./data`` folder instead of the ``public`` folder.
diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst
index 1f43139a8580..1a8d3e2bf79b 100644
--- a/user_guide_src/source/database/configuration.rst
+++ b/user_guide_src/source/database/configuration.rst
@@ -38,7 +38,7 @@ prototype::
The name of the class property is the connection name, and can be used
while connecting to specify a group name.
-.. note:: The default location of the SQLite3 database is in the ``writable/data/`` folder.
+.. note:: The default location of the SQLite3 database is in the ``./data/`` folder.
If you want to change the location, you must set the full path to the new folder.
Some database drivers (such as PDO, PostgreSQL, Oracle, ODBC) might
diff --git a/writable/data/index.html b/writable/data/index.html
deleted file mode 100644
index b702fbc3967b..000000000000
--- a/writable/data/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
-