I want to change the URL from one to another. Exactly from this:
https://example.com/pages/page.php
to this:
Physically page.php is in the /pages folder and I want to left it like that. I want to change the visible URL only.
I've tried to use rewrite with htaccess like this:
RewriteRule ^pages/(.*)$ /$1 [R=301,NC]
but it returns 404.
Update
I've tried this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ pages/$1 [L]
and now I see page.php from both https://example.com/pages/page.php and https://example.com/page.php without 404.
BUT it's still not exactly what I expected. I want after going here https://example.com/pages/page.php to see: https://example.com/page.php