Here's my full case:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?$1 [QSA,L]
</IfModule>
<VirtualHost 127.0.0.3:80>
ServerName mvcframe.local
DocumentRoot /var/www/html/mvcframework/public
<Directory /var/www/html/mvcframework>
Options -Indexes +FollowSymLinks
AllowOverride All
</Directory>
ErrorLog /var/www/html/mvcframework/mvc-error.log
CustomLog /var/www/html/mvcframework/mvc-access.log combined
</VirtualHost>
When I access http://mvcframe.local or http://mvcframe.local/ it outputs index.php content inside public folder index.php as it should.
When I access http://mvcframe.local/?posts/hello it outputs:
Requested URL = posts/hello
Not Found
The requested URL was not found on this server.
Apache/2.4.41 (Ubuntu) Server at mvcframe.local Port 80
I am trying to figure out the solution searching for 2 hours and still haven't got the solution for it.
Alright, so after messing around and reading .htaccess tutorials for hours, I finally managed to understand my mistake. First of all, here is the video which helped me understand my mistake.
Here's my solution:
<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?$1 [QSA,L]
</IfModule>
First, I am checking if mod_rewrite is enabled. Then providing some options. Then turning on the RewriteEngine which is neccessary for enabling rewriting rules. Then giving the Rewrite Conditions for [If no directory] and [If not file] for whatever query is being supplied, for which I rewrite the rule basically telling it that check for all string that doesn't end with extension ".", simply direct them all to index.php?$1.
Basically anything that has mvcframe.local/something_here/some_here/... will become automatically mvcframe.local/index.php?something_here/some_here
For my setup, index.php is the frontloader so everything must go through this file.