Answer the question
In order to leave comments, you need to log in
Problems with cnc in php?
Hello, I'm learning php, I'm trying to create my own CNC single entry point for experience without a framework.
It works like this:
.htaccess redirects all requests to the index.php page. And already index.php works as a single entry point
data from index. php:
if ( $_SERVER['REQUEST_URI'] == '/' ) {
include 'html/main.inc.php';
} else {
$page = substr($_SERVER['REQUEST_URI'], 1);
$pg = explode('?', $page, 2);
if ( count($pg) >=2 && $filename = 'html/'.$pg['0'].'./'.$pg['1'].'.inc.php' && file_exists($filename) ) {
include $filename;
} elseif ( $filename = 'html/'.$pg['0'].'.inc.php' && file_exists($filename) ) {
include $filename;
}
if ( file_exists('html/'.$pg['0'].'.inc.php') ) {
include 'html/'.$pg['0'].'.inc.php';
} else {
if ( $_SERVER['REQUEST_URI'] != 'html/'.$pg['0'].'.inc.php') {
include "html/error.inc.php";
}
}
}
Answer the question
In order to leave comments, you need to log in
Firstly, mysql has nothing to do with it - you need to read about mod_rewrite
Secondly, there are many articles on the Internet.
For example: crazy-russian.ru/development/kak-sdelat-chpu-s-pom... or www.chuvyr.ru/2014/02/create-friendly-url-htaccess...
What you need is called : CNC or SEF
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question