keeps21 Posted February 20, 2009 Share Posted February 20, 2009 So I have an installation of WAMP running on my computer for development of applications. Currently each application is in a subdirectory www/app1 www/app2 www/app3 etc. What this means is that my scripts refer to http://localhost/app1/, http://localhost/app2/, http://localhost/app3/ etc Meaning that when I upload to a server my scripts need to be changed to use the www directory rather than a sub directory. What's the best way to overcome this - use of code? or run a different test server for each application and use the www root? Cheers for any advice. Quote Link to comment https://forums.phpfreaks.com/topic/146138-solved-development-server/ Share on other sites More sharing options...
jcombs_31 Posted February 20, 2009 Share Posted February 20, 2009 I really don't understand the problem. Why don't you just copy the contents of app1 to the web root of your live server? And so on with the rest. Quote Link to comment https://forums.phpfreaks.com/topic/146138-solved-development-server/#findComment-767180 Share on other sites More sharing options...
PFMaBiSmAd Posted February 20, 2009 Share Posted February 20, 2009 If you are hardcoding the path within your code, you need to use a way that is independent of where the code resides. Post an example of what you are doing in your code. Quote Link to comment https://forums.phpfreaks.com/topic/146138-solved-development-server/#findComment-767201 Share on other sites More sharing options...
nrg_alpha Posted February 20, 2009 Share Posted February 20, 2009 What's the best way to overcome this - use of code? or run a different test server for each application and use the www root? While I'm not familiar with WAMP (I use XAMPP), my root folder is htdocs.. so if I place files in the root of htdocs, it doesn't matter if things are running on localhost or remote server.. the files will be accessible: '/somefile.php' <= somefile.php in the root. So if in WAMP, www is supposed to be your root folder, I would guess that you don't include 'www' in your file paths (perhaps just /?), as this is probably already understood as your sites root? Quote Link to comment https://forums.phpfreaks.com/topic/146138-solved-development-server/#findComment-767295 Share on other sites More sharing options...
zq29 Posted February 22, 2009 Share Posted February 22, 2009 You should look into Virtual Hosts within Apache, this should solve your problems. Quote Link to comment https://forums.phpfreaks.com/topic/146138-solved-development-server/#findComment-768432 Share on other sites More sharing options...
keeps21 Posted February 23, 2009 Author Share Posted February 23, 2009 I've solved this by specifying the site url and the abs path to the site files as constants in my config file. Then just used those constants in my pages where needed. That way I'll just need to change those two variables in the config when the site goes onto a live server. Quote Link to comment https://forums.phpfreaks.com/topic/146138-solved-development-server/#findComment-768995 Share on other sites More sharing options...
nrg_alpha Posted February 23, 2009 Share Posted February 23, 2009 Something tells me you shouldn't have to do that (change variables to go from localhost to server). The idea should be that the localhost is set up in such a way that any paths you specify in your code (from the root on outwards) should work regardless whether you are testing on localhost or using a remote server. The code should be portable, and as a result, you shouldn't need to mess around with absolute path configurations. Quote Link to comment https://forums.phpfreaks.com/topic/146138-solved-development-server/#findComment-769101 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.