1

I have web application. i am using WAMP server. I have developed web application and put my application files under "login" and then in "www" folder of wamp.i.e. Drive:\wamp\www\login\ now when upload my file to the web host that goes directly to "www" folder and there is no "login" folder there. so my existing links on localhost e.g.

http://localhost:8081/login/dashboard.php

turning to http://example.com/login/dashboard.php. now as there is no login folder, because of wrong path, link is breaking. there is one way, that i change every link everytime before uploading to webserver, which is time consuming and prone to errors. is there any simple way i.e. dynamic way that my links work perfect both on localhost as well as web server. so that the link on localhost on web server the link should be http://localhost:8081/login/dashboard.php direct automatically to http://example.com/dashboard.php instead of http://example.com/login/dashboard.php

i tried using $_SERVER["DOCUMENT_ROOT"] but it point local drive path and did not work well for me.. any help really appreciated.

The_Amol
  • 309
  • 3
  • 15
  • Can you share the code you use to create the link ? – Nirnae Feb 09 '16 at 12:00
  • So create a similiar folder structure on the Server so it matches your testing environment. Or create a Virtual Host for your site on WAMPServer and recode to work there, also so that TESTING ENV matches LIVE ENV – RiggsFolly Feb 09 '16 at 12:07
  • Thanks RiggsFolly for your suggestion. it solved my problem by creating "login" folder in root directory of web server. but still i want to know how i can get it done if "login" folder is not there i.e. not similar structure as localhost. – The_Amol Feb 09 '16 at 12:28

1 Answers1

0

Have you tried to work with relative paths?

$path = "/login/etc..."

This way you don't have to change the paths each time. I think php even has a function to turn relative paths to absolute ones.

Zanidd
  • 133
  • 13