If a user extracted the files of my php application to example http://example.com/test/webapp/, the absolute links in my application won't work anymore.
How can I get the path /test/webapp/ to add it to my absolute links?
You can with:
dirname( $_SERVER["SCRIPT_NAME"] );
make sure your links are always relative in your pages, so when you move your site to another domain they still work.
Check out all other $_SERVER variables by executing phpinfo() .
for redirecting, you can use:
header('Location: https://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']) . '/some_page.php');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With