How to redirect user from any page on the main?

Is there a website where a lot of pages. It is necessary when the user comes to the site to redirect to the main page.
There are options of code. But I don't understand in which file this code to write and where it should be.
In the video the person just created a file "1" without any extension and put it in the root of the site and it all worked. The opportunity to ask the author there.
In General, ideally, that the redirect was not from all pages, but only with those which lie in a special folder(there is a website in the website have a sitemap folder, ideally only from pages located in this folder is redirected to home).
On the Internet I saw the option .htaccess , but something I have it worked badly.
HELP don't know what to do!
April 7th 20 at 10:43
1 answer
April 7th 20 at 10:45
What kind of web server? Apache? Then using .htaccess Google how to set
nginx? Then Google redirects in nginx

You any entries not given. Where exactly are you all trying to do a redirect? At the level of the web server backend for your app or at the front? What you tried to do?

In General, ideally, that the redirect was not from all pages, but only with those which lie in a special folder


Redirect is not done "from all pages in the folder," and with certain URLs.

Find more questions by tags PHP