I will have multiple folders/modules to access common files. But accessing them seems to be big deal for me!
I did gone through this link to understand the relative pos
./css/style.css
means from current directory and would achieve the same result as css/style.css
. The easiest answer is to determine what the base path of your application is and use that. For instance, if your application is running as http://myapp.com
, then you could set all your front-end paths to /css/style.css
. If your app runs in a subdirectory, such as http://example.com/myapp
, then your paths would be /myapp/css/style.css
.
This does not apply the same on the PHP side. For them, you should really use document-relative paths. Having a PHP file that you include in multiple places in your app, the contents of which having something like include('../myDoc.php');
, can lead to complications as the path isn't based on the included document's path, but rather the including. So using document-relative paths, you get around this include(__DIR__ . '/../myDoc.php');
. Just something to consider if your app grows.