PHP Application URL Routing Removing file extensions

Rate this post

Today, We want to share with you PHP Application URL Routing Removing file extensions.
In this post we will show you Basic page routing in PHP, hear for Removing file extensions in PHP we will give you demo and example for implement.
In this post, we will learn about how to hide php extension in url with an example.

PHP Application URL Routing Removing file extensions Demo

I learn To how to secure php website from hackers for best website security.

[php]
mkdir -p router/public router/partial
cd router/public
php -S localhost:3000
[/php]
[php]
echo ‘admin is where the heart is’ > partial/admin.php
echo ‘this is a site contact nothing’ > partial/contact.php
echo ‘oh noes!!~!’ > partial/404.php
[/php]

READ :  AngularJS Filter inside controller - angular custom filter example

The core PHP simple router source code will live in simple File on root public/index.php and need look something like this below Example:

[php]
<?php
// Grabs the PHP URI and some breaks it apart in this case I have main PHP querystring stuff
$request_uri = explode('?', $_SERVER['REQUEST_URI'], 2);

//core PHP Route it up!
switch ($request_uri[0]) {
// Admin page
case '/':
require '../partial/admin.php';
break;
// Contact page
case '/contact':
require '../partial/contact.php';
break;
// Everything else
default:
header('HTTP/1.0 404 Not Found');
require '../partial/404.php';
break;
}
[/php]

jQuery 15 Powerful Tips and Tricks for Developers and Web Designer

Lastly We have this file saved, and go back to your any browser and simple refresh it.

READ :  Creating Angular 6 Hello World Application

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP URL Routing Removing file extensions.
I would like to have feedback on my Infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Reply

Your email address will not be published.