htaccess PHP | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

htaccess PHP

Help me please, I need this: learn-html5/lesson to change on this: learn-html5/overview or learn-html5/basic when I have a link with GET parameter like: sitename/leart-html5/lesson?id=basic

7th Mar 2019, 1:36 PM
coding-space.ru
coding-space.ru - avatar
4 Answers
+ 1
What you seem to want is called REST API. It can be created with PHP only (but will be very difficult, and NOT just one file) So, there are frameworks like Laravel, CI and more to make the job easier. Using REST API, you can create custom "Routes" like "learn-html5/path" and path can be anything that is checked by the "Controller" to generate data as per the path. REST: https://searchmicroservices.techtarget.com/definition/RESTful-API With just 1 file, like that, it is not possible.
7th Mar 2019, 3:05 PM
Niush
Niush - avatar
+ 1
Something like this will work: I don't think you should work with htaccess. if(isset($_GET['id']){ header("Location: learn-html5/".$_GET['id']); die(); }
7th Mar 2019, 2:24 PM
Niush
Niush - avatar
+ 1
Okay, thank you. I will try it with REST API
7th Mar 2019, 3:44 PM
coding-space.ru
coding-space.ru - avatar
0
I work with 1 file where content will be form from database by last parameter in my URL. So, I have only "lesson" file with function of reading URL and it forms content by last parameter
7th Mar 2019, 2:37 PM
coding-space.ru
coding-space.ru - avatar