I am trying to use the .htacces file to redirect any files or subfolders in a derectory to one file, while still maintaining the original URL input.
So if a user goes to:
https://example.com/folder1/folder2/folder3/
or
https://example.com/folder1/folder2/file.php
it would redirect them back to:
https://example.com/folder1/index.php
but the original URL input would not change.
You can use
RewriteRule. In htaccess in the document root add the following rule:This will redirect
/folder1/foo/barto/folder1/index.phpwithout changing the url in browser.The
RewriteCondabove makes sure you don't rewrite/folder1/index.phpto itself (/folder1/index.php) otherwise the rule can cause an infinite loop error.