Ronny Dark Team Ronny Dark Team -3 years ago 153
Apache Configuration Question

GET request as directory

I want to make this Social Network-ish thing, and I want user profiles to be located at www.mywebsite.com/[profile-name], but the thing is that I don't know how to do this. I can't use Laravel or anything like that. Only PHP.

Here are some solutions I came up with, but I don't know if they are possible or how to actually make them into code:


  1. Make PHP actually create all of the directories and copy a index.php into it. (idk how to make this)

  2. Somehow, make PHP recognize what comes after the "/" and treat it as a variable, just like a GET variable (here is where the title of the question comes from, because this is actually what I had in mind doing), but I have no idea how to do that. Maybe making the 404 page actually look at the url, and then redirect you? Yeah idk... Maybe you can help me. I would prefer just answering this question rather then you thinking about a solution or answering the first solution, but anything is welcomed. Thanks!


Answer Source

Larasvel is build using PHP ;) If you are going to build a social network solution, it is strongly recommended to use an established framework like Laravel, Yii2 etc. Why? Because it has tons of out of the box functionality you can use.

That said, you need to learn how to use PHP routing. Here is one solution. http://blogs.shephertz.com/2014/05/21/how-to-implement-url-routing-in-php/

Here is another routing solution: https://longren.io/basic-routing-in-php-with-altorouter/

You can also consider using javascript framework like vue.js for routing.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download