samedi 17 août 2019

How to check URL's structure in PHP?

All my site's URLs have the following structure:

https://www.example.com/section/item

where section is a word and item is a number.

So, possible URLs are:

https://www.example.com

https://www.example.com/section

https://www.example.com/section/item

By .htaccess, all requests go to index.php (route).

I want to show a 404 error message if user types:

https://www.example.com/section/item/somethingelse

How can I do it using PHP?

Thanks.

Aucun commentaire:

Enregistrer un commentaire