D
D
Dmitry2017-07-16 15:57:50
PHP
Dmitry, 2017-07-16 15:57:50

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";

        }

    }

}

And I want to implement such that when, let's say, they go to the "cat.inc.php" page, it goes through index.php and gives the page already with this one without an ending, that is, "cat". So I want to implement such that, let's say I upload information from mysql via get and the link looks like this site.com/cat?link=rapap, but I want it to be like this site.com/cat/rapap . I
tried to google, but all the settings are through htaccess does not work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2017-07-16
@gromdron

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 question

Ask a Question

731 491 924 answers to any question