^

SEO Friendly URLs with PHP

Article 43 in PHP

2020-08-26 01:30:46 from bugfish
SEO Friendly URLs with PHP
PHP / URL Request Handling
Last Review on: 2021-02-27 07:09:29 | Hits: 159

 

Modify your HTaccess File like this if index.php is your main php File:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?i=$1 [L,QSA]

  For example, if the user enters the URL yourdomain.ending/wiki/testcategorie
you can fetch the url parameters like this in your PHP Script:

     $location = explode("/", htmlspecialchars(@$_GET["i"]));

Location is now a array with the URL values inside it.

In our example
yourdomain.ending/wiki/testcategorie

The array would be like:

location[0] = wiki
location[1] = testcategorie

Now you can load your modules with a switch/case loop or do anything else what you need to do with that
URL informations.

 

I do not guarantee the reliability of the information given here, the code described on this page is executed at your own risk and in the event of damage or other unforeseeable consequences I am in no way responsible or liable.
Comment Section
Currently 0 Upvotes!
captcha image

System - 2021-01-01 19:30:37
We appreciate comments on our site!

This Website is using Session Cookies for Site Functionality and AWStats.
Radio