Answer the question
In order to leave comments, you need to log in
How to do routing in htaccess?
Hello!
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
RewriteRule ^users(.+)$ index.php?url=users&page=$1 [QSA,L]
define('SKYLIGHT',dirname(__FILE__));
# Шапка
include('inc/head.php');
$url = $_GET['url']; // site.ru/url=название
if(isset($url)){
if(file_exists(dirname(__FILE__)."/pages/".$url.".php")){
include(dirname(__FILE__)."/pages/".$url.'.php'); // Ищем файл в директории
}else{
include(dirname(__FILE__).'/pages/404.php'); // Страница 404
}
}else{
include(dirname(__FILE__).'/pages/main.php'); // Главная страница
}
# Подвал
include('inc/foot.php');
include ('./inc/menu.php'); // Меню пользователя будет со всеми страницами в /pages/user/
$url2 = $_GET['page'];
if(isset($url2)){
if(file_exists(dirname(__FILE__)."/user/".$url2.".php")){
include(dirname(__FILE__)."/user/".$url2.'.php'); // Ищем страницы
}else{
include(dirname(__FILE__).'/404.php');
}
}else{
include(dirname(__FILE__).'/user/acc.php'); // Профиль основная в /user/
}
Answer the question
In order to leave comments, you need to log in
Please do not advise MVC.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question