How to access non-local site while using local Wamp server to develop the same site?

Hi,

I’ve been developing a website on my localhost machine using Wamp server. Now I want to move the site to a non-local hosted machine.

I have a html test page on the non-local host. I can’t access the page. I’ve tried to exit Wamp and still can’t access the site test page.

On my local machine in the etc/host file I have my site.

How can I keep developing my site on my localhost machine and at the same time access the non-localhosted site?

Understand?

Thanks

It sounds like you have a dns mapping issue? Make sure you remove any overwrite in your hosts file that has to do with your site address. http//localhost should take you right to your local dev site, and yourname.com should be taking you to the remote, production website.

I guess I am a little confused on where, your confusion is.

I guess you configured your site on wamp as yourdomain.com

Change this to yourdomain.local so you know which is remote and which is local.

Okay, let me explain better.

I can go to my site on my localhost machine like this: [noparse]http://www.mysite.com[/noparse]

It’s set up on my machine like that, not [noparse]http://localhost[/noparse] (I read to set it up that way to make sure all the links created for the site would be transferable when going live.) If I go to [noparse]http://localhost[/noparse] I’ll go to my Wamp administration panel.

I thought I might have to remove the code out of my local “host” file i.e. C:\Windows\System32\drivers\etc\host.conf

Here’s what I have in the host.conf file:

::1 localhost
127.0.0.1 localhost mysite.local
127.0.0.1 mysite
127.0.0.1 mysite.com
127.0.0.1 [noparse]www.mysite.com[/noparse]
127.0.0.1 postmaster.mysite.com
127.0.0.1 admin.mysite.com
127.0.0.1 mail.mysite.com
127.0.0.1 care.mysite.com
127.0.0.1 webmaster.mysite.com

In my Wamp Server set up I have this:

<VirtualHost *:80>
ServerAdmin [noparse]admin@mymysite.com[/noparse]
ServerName [noparse]www.mymysite.com[/noparse]
ServerAlias [noparse]www.mymysite.com[/noparse]
DocumentRoot C:/Windows/HOST/wamp/www/www.mymysite.com
ErrorLog “logs/error.log”
CustomLog “logs/access.log” common
<Directory “C:/Windows/HOST/wamp/www/www.mymysite.com/”>
Options Indexes FollowSymLinks
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>

As you can see I’m set up to host the site on my localhost machine. I changed my mind about that!

But it helps making sure the links are correct in the site thou.

Now I want to upload the site to another non-localhost.

But I want to keep my set up here because it works so well and I know the links created will work. If I put mysite name into my browser it will take me to my localhost machine (I think because of my host file).

My problem seems to be how to go to my site on this “localhost” machine (when I want to) when I want to work on my site here and go to my non-localhost to set up everything else. I would like to switch between both. That would be ideal.

It looks to me like I’m going to have to remove to code out of my host.conf file, refresh windows memory, and maybe even do something about the Wamp VirtualHost conf file too.

I thought I could least access mysite with the ip number, but that’s not working either. But even if I could access mysite through the ip address when ever I click a link it would automatically bring me back to my localhost machine.

Know what I mean?

Thanks

hosts file should only contain:

::1 localhost
127.0.0.1 localhost mysite.local

You are literally pointing mysite.com to your own machine with the rest of the lines.

I believe after you fix that, the virtual host should be fine? If not change that to localhost as well

Will that mess up my links?

So I would go to [noparse]http://www.mysite.local[/noparse] on my localhost?

I can try it but I don’t see how it would work.

Thanks

After removing your custom lines from your hosts file, you’d go to [noparse]http://locahost[/noparse] for your local dev server. Your links should be formatted as “/home” and not “mysite.com/home” though, unless you have a variable set on them all that can be changed depending wether your in production or dev ex. $siteUrl & “/home”;

Please turn off automatic parsing of URLs (via the “Go Advanced” button) or wrap [noparse] tags round them when you’re giving examples. (Especially if you’re going to use mysite.com as your example, because that’s a real site.) It will save me tearing out my fur in frustration. :slight_smile: Thank you.

I have to remove all the code out of the host file then reboot the router then I can go online to my site.

It works but not as convenient as I would like.

Yes, I didn’t realize about the links, sorry.

You need to reboot your machine, not your router. All that is needed to take your site live is a mysqldump of the database (if you have one), and mirror to the remote site, and a simple copy and paste of your site directory to the remote site. There’s other little tricks you’ll think of as you dig in deeper.

I’m not sure what you mean. I don’t think I can because I have a dynamic IP. I have MySql installed and even Bind DNS. But my machine would probably be to slow. I have a Magento cart I’ve been working on for a few months (hard cart) but I like it. It’s loaded and I need at least three databases.

What I would like to find is a free hosting company with everything I need to run my cart and that I can upgrade later for speed. I would like my profits to pay for everything. Something is the matter with every hosting company so far. I think I need a dedicated IP with free hosting and more than one database. You don’t know everything about the hosting companies untill you sign up. Then you find out the something is wrong. I found a place to get a free SSL for accepting CC but I think I need a dedicated IP.

What do you mean “mirror the remote site?”

@FreeJoy

Most of the problems I had when developing locally and then uploading was paths and passwords, etc. To prevent having separate files with the same name for localhost and online I came across this neat solution:



<?php

defined('LOCALHOST') ?: define('LOCALHOST', 'localhost' === $_SERVER['SERVER_NAME']);

if( LOCALHOST )
{
// Necessary to remove DRIVE letter
  define('PATH_INDEX', substr(getcwd(),2)) .'/';

  define('PATH_ASSETS', '.assets/');
  define('PATH_IMAGES', '/xamp-lite/xampp/htdocs/afiles/images/');
  define('PATH_THUMBS', "/subdomain/thumb/");
}
else
{
  define('PATH_ASSETS',   '/home/content/77/123456/html/assets/');
  define('PATH_IMAGES',   '/home/content/77/123456/html/xy_john/afiles/images/');
  define('PATH_THUMBS',  '/home/content/77/123456/html/subdomain/thumb/');
}

?>


<!-- common links can be used on same file for both localhost and online -->
<a href='/file-with-image-123.jpg'>
  <img
      src   = '<?php echo PATH_THUMBS;?>thumb-123.jpg'
      style = 'width:88%; max-width:123px'
      alt='#'
  />
</a>



As I suspected you have your remote site name set up locally.

Your options are use a local site name and use relative links (what we and the majority of developers do).

Or have two host files. One with your sites and one without. When you want remote access switch the files over (call one hosts_local and one hosts_remote. When you want to use it rename it to hosts.) then when you have the right host file in place run the following command in the run box

Ipconfig /flushdns

Personally the first option is much easier and what the rest of the planet does.