Мне нужна помощь с моим PHP-кодом. Вот код, о котором я буду говорить:
<?php
$default = 'about'; //Whatever default page you want to display if the file doesn't exist or you've just arrived to the home page.
$page = isset($_GET['p']) ? $_GET['p'] : $default; //Checks if ?p is set, and puts the page in and if not, it goes to the default page.
$page = basename($page); //Gets the page name only, and no directories.
if (!file_exists('content/'.$page.'.php')) { //Checks if the file doesn't exist
$page = $default; //If it doesn't, it'll revert back to the default page
//NOTE: Alternatively, you can make up a 404 page, and replace $default with whatever the page name is. Make sure it's still in the inc/ directory.
}
include('content/'.$page.'.php'); //And now it's on your page!
?>
Хорошо, это вызовет "about.php" в качестве моей индексной страницы из-за кодировки, следующей за ней. Тем не менее, я бы хотел, чтобы страница индекса по умолчанию вызывала страницу URL, например "http://www.mywebsite.com/frontpage/". Я пытался заменить" about "на URL, и он просто добавляет расширение" .php "в конец URL. и '/ content' в начале URL-адреса. Из-за этого я получаю сообщение об ошибке PHP.
Может ли кто-нибудь помочь мне с кодом, который будет делать то, что я действительно хочу (как обсуждалось выше)? Спасибо:)