Very often I see that on sites after going to a page there is no page extension in the address bar. For example, ruSO Help , the address looks exactly https://ru.stackoverflow.com/help , and not https://ru.stackoverflow.com/help.php or https://ru.stackoverflow.com/help.html . How exactly is this done? And what is this technology?
Plus, immediately a question from the same opera, but about the site's api . For example, take Vkontakte. The method call is as follows:https://api.vk.com/method/METHOD_NAME?PARAMETERS&access_token=ACCESS_TOKEN&v=V
That is, after METHOD_NAME there is no .php , and on some other sites there is. Plus, I also met something like METHOD_NAME#... What does all this mean and how is it implemented? And what are the advantages of each?
UPD
Did, it turned out. apache server
Did as follows:
index.php - at the root, other pages in the pages folder
My problem with headers already sent by... solved as follows. I incorrectly approached the solution of the problem, in the index.php file I just need to handle redirects, and I stuffed the contents of the main page there.
In .htaccess wrote at the beginning of the following:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> Then in the index.php file:
<?php $url = explode('/',strtolower(substr($_SERVER['REQUEST_URI'], 1))); switch($url[0]) { case '': { //Если пусто в адресе, то направляем на главную include 'pages/main_page.php'; break; } case 'news':{ include 'pages/news_page.php'; break; } case 'buy':{ include 'pages/my_buy_page.php'; break; } case 'somepage':{ include 'pages/somepage.php'; break; } } ?> Interestingly, the includes folder is at the same level as the pages , include folder in a file, for example, pages/news_page.php should be written without ../ , that is, just include ('includes/foobar.php');
Everything works, thanks @Stanislav, for the hint