A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_URI::$config is deprecated
Filename: core/URI.php
Line Number: 102
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Router::$uri is deprecated
Filename: core/Router.php
Line Number: 128
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$benchmark is deprecated
Filename: core/Controller.php
Line Number: 83
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$hooks is deprecated
Filename: core/Controller.php
Line Number: 83
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$config is deprecated
Filename: core/Controller.php
Line Number: 83
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$log is deprecated
Filename: core/Controller.php
Line Number: 83
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$utf8 is deprecated
Filename: core/Controller.php
Line Number: 83
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$uri is deprecated
Filename: core/Controller.php
Line Number: 83
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$exceptions is deprecated
Filename: core/Controller.php
Line Number: 83
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$router is deprecated
Filename: core/Controller.php
Line Number: 83
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$output is deprecated
Filename: core/Controller.php
Line Number: 83
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$security is deprecated
Filename: core/Controller.php
Line Number: 83
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$input is deprecated
Filename: core/Controller.php
Line Number: 83
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$lang is deprecated
Filename: core/Controller.php
Line Number: 83
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$db is deprecated
Filename: core/Loader.php
Line Number: 397
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_DB_mysqli_driver::$failover is deprecated
Filename: database/DB_driver.php
Line Number: 372
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$email is deprecated
Filename: core/Loader.php
Line Number: 1284
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 303
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_cookie_params(): Session cookie parameters cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 328
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 355
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 365
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 366
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 367
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 368
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 426
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_save_handler(): Session save handler cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 110
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_start(): Session cannot be started after headers have already been sent
Filename: Session/Session.php
Line Number: 137
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$session is deprecated
Filename: core/Loader.php
Line Number: 1284
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$form_validation is deprecated
Filename: core/Loader.php
Line Number: 1284
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$pagination is deprecated
Filename: core/Loader.php
Line Number: 1284
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blog::$zip is deprecated
Filename: core/Loader.php
Line Number: 1284
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$load is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$benchmark is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$hooks is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$config is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$log is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$utf8 is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$uri is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$exceptions is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$router is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$output is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$security is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$input is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$lang is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$db is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$email is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$session is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$form_validation is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$pagination is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$zip is deprecated
Filename: core/Loader.php
Line Number: 932
Backtrace:
File: /www/wwwroot/SINHCOMS/VT/main/application/controllers/Blog.php
Line: 20
Function: view
File: /www/wwwroot/SINHCOMS/VT/main/index.php
Line: 160
Function: require_once
Vismrit Tech | Home Startup
Theresa Underwood
Sep 10, 2021
9 min to read
We wanted to create the absolute most basic routing code in PHP, so here it is. We will direct ALL traffic to index and route to the new files from here.
Redirect all requests to index.php In the root of your project, create a .htaccess
file that will redirect all requests to index.php
.
.htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php [QSA,L]
Create a routing switch Get the requested path with $_SERVER['REQUEST_URI']
, and require the page you want to display. I have ''
and '/'
for both url.com/ and url.com .
index.php
<?php
$request = $_SERVER['REQUEST_URI'];
switch ($request) {
case '/' :
require __DIR__ . '/home.php';
break;
case '' :
require __DIR__ . '/home.php';
break;
case '/about' :
require __DIR__ . '/views/about.php';
break;
default:
http_response_code(404);
require __DIR__ . '/error.php';
break;
}
Create the views Create a /views
directory and place the files.
/home.php
/views/about.php
/error.php
That's it!
Files on Github
Related Post
Demand generation is a constant struggle for any business. Each marketing strategy you employ has...
Learn more
Organic search has the potential to capture more than 40 percent of your gross revenue...
Learn more
Demand generation is a constant struggle for any business. Each marketing strategy you employ has...
Learn more
Sophie Asveld
February 14, 2021
Email is a crucial channel in any marketing mix, and never has this been truer than for today’s entrepreneur. Curious what to say.
Ariana Gerad
February 14, 2021
Email is a crucial channel in any marketing mix, and never has this been truer than for today’s entrepreneur. Curious what to say.
Sophie Asveld
February 14, 2021
Email is a crucial channel in any marketing mix, and never has this been truer than for today’s entrepreneur. Curious what to say.