codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.35k stars 1.9k forks source link

Dynamic URL #4394

Closed muh-ramadhan closed 3 years ago

muh-ramadhan commented 3 years ago

Can I add dynamic url to minimize configuration.

MGatner commented 3 years ago

Read the User Guide on Routing: https://codeigniter.com/user_guide/incoming/routing.html

If you need more assistance, support questions need to be directed to the CodeIgniter Forums. GitHub is for bug reports and discussed feature requests.

muh-ramadhan commented 3 years ago

thanks sir, I mean can I add dynamic url function. in public $ baseURL and add a few lines in the Constants.php file

muh-ramadhan commented 3 years ago

whether these changes are allowed, if I change the line public $baseURL = 'http://localhost:8080/'; become public $baseURL = 'DYNAMIC_BASE_URL'; then add the line DYNAMIC_BASE_URL to app\Config\Constans.php

iRedds commented 3 years ago

curl -H "HOST: Ass On Fire" http://target Have fun.

lonnieezell commented 3 years ago

To make the base URL dynamic in the main framework is to introduce a security risk, since as @iRedds pointed out it can be set as anything by the end user. That's why it's done the way it's done currently. Obviously, you're free to make your own decisions on your application and the situation it will be used, but unless for a very specific reason I wouldn't suggest it just to make your life simpler. If you do need that, make sure you have whitelist in place to check them against. Besides - using the .env file to set your baseUrl is pretty similar to what you're asking for.

muh-ramadhan commented 3 years ago

thank you sir, what you have conveyed is input for me.

mridah commented 3 years ago

@muh-ramadhan Were you able to use dynamic baseURLs ?