Can I edit the hosts file to see the new website and still access the old one? - wordpress

I'm developing a new website that will have the same domain name as the current old one, but a different host. The new one doesn't have DNS nameservers pointed to it yet, but I edited the hosts file on my computer to be able to access it. Is there a way I can now still access the old current one on the same computer, since it would help me with development, without changing the hosts file everytime?
Thanks :)

You can check the old site by using the temporary URL
http://server_ip/~cpanelusername/
but many of host block ip preview. You also can use archive.org. You can save the old site before starting new.
For this type scenario, I use a subdomain to built a new site.
www.mysite.com >> www.dev.mysite.com

If possible, it can be helpful to set up an alias and then create an A record for that alias that points to the new site. This allows you to reach the new site via a different name but it will still look at all the files and database(s) as it would normally.
This is helpful for when you want to test the new site before it goes live without having to comment and uncomment the hosts file continuously.
One thing to watch out for is that any URLs that are the full URL such as example.com/whatever instead of /whatever won't work. However, as it is generally bad practise to do the full URL in case the domain ever changes; this can be a good way of finding and corrected any.

Related

Error establishing database connection if i dont type https before domain

Site worked properly till recently when i got EEDBC error. Accidentaly realised that i can get to ebsite only if I type https before domain. What could be the problem? (And solution, of course)
You need to pay close attention to whether the URLs that you found have www. included. If your database includes a URL without it or vice versa, then this needs to be changed to match your database.
Check the wp-config.php file in your directory and change it. Without seeing the config file I could not answer the exact answer.
The prolem was, that my hosting provider moved directory from subdirectory to root folder on their own without notice

Moving ASP.net site to another server

Assume I have asp.net websites on Server1 and need to move them to Server2, what is the best practice for this and how do I ensure that all relevant files, databases, etc are moved as well? Am I going to have to manually amend all the web.configs and other config files, plus find out what dependencies each site has, or is there a way to just export everything and import to the new server?
I have not found anything else on SO that has instructions for this.
Thanks
Edit: This is similar but not the same as the other question. The other question doesn't actually provide an answer, just some ideas about staging environments.
I'd like this to be as automated as possible due to having about 30 applications to move. The new server is pretty much identical but I noticed that when I moved one application using 'Web Deploy' as a test, it didn't bring over the dependencies and I had to manually find out which ones were missing and install them.
how do I ensure that all relevant files, databases, etc are moved as
well?
Typical asp.net sites have all data, and database under the one main directory. So you just copy/paste the full directory from the old to the new one server.
But we have some points to note here.
DataBase files are locked by the database, so you need to first remove them from the database.
In the new site you need to remount the database files and change the web.config according to the new server (eg, maybe new ip address, new names on database.
and finally the permissions on the new host must be correct and the same, if you have for example some directory that you need write permissions, you must add it also to the new server
You can also read: How to set correct file permissions for ASP.NET on IIS

Drupal Commerce Kickstart - Making Test site of Live site

I want to do developments on my client's website but by making a clone of it. So, main website url is: http://website.com and the clone i am trying to create is: http://test.website.com.
So far i've done the following:
copied entire root directory into public_html/test dir (with folders config,field,FirePHPCore,fontyourface,includes,js,misc,modules,scripts,sites,styles and themes)
created a subdomain in cPanel for test.website.com
checked the file settings.php (inside sites/default folder) for $base_url but found it commented, so left it as it is unchanged.
copied db via phpMyAdmin and updated the new db details in settings.php (inside sites/default folder).
inside the table variable, two rows with the name securepages_basepath and securepages_basepath_ssl. Changed their values from http://website.com to http://test.website.com (using the variable_get and variable_set functions).
Now i can access http://test.website.com but when i click on login (from header) it takes me to http://website.com/user and if manually type http://test.website.com/user and login then it takes me to http://website.com/users/admin then i have to manually type in correct address http://test.website.com/users/admin.
And when i logout, it again takes me back to http://website.com.
So i want to know how can i completely make it to work on http://test.website.com?
Are there more variables to change?
And how i can make 100% sure that the test site is only using test and not the live site. I am afraid of messing up live website.
Please advice, thanks!
I fixed it by disabling the secure pages from inside the mysql database. It was inside variable table and securepages_enable field. It was in blob so i had to download the blob first and opened it in notepad and changed the value inside it from 1 to 0 and then uploaded it back by updating the securepages_enable field.
I had to do this because after logging in from my test url, the urls were redirecting back to the live website, so whatever change i was making, it was all affecting the live site.
Hope this helps to someone with similar case. Thanks!

.aspx file doesn't work on IIS website

I have a big solution that contains a lot of .aspx file, basically it's a big sln file for my whole server
I wanted to add a website in my IIS server that contains inside a child directory within the root site folder, for example:
my-tools.com physical path is D:/MyWeb <-- Working well
I added a secondary sites, with no relation to the upper site called mysite which is like that:
mysite.my-tools.com which its path it D:/MyWeb/MySite/
If I try to reach mysite.my-tools.com/M_Index.aspx file it give me an error tells me it's not found, however, when I try to view a .jps file from the same directory (e.g mysite.my-tools.com/test.jpg) it returns just find.
it's important to tell that all the pages share the same solution, what do I do here and why it is not working? can anyone tell me?
thanks a lot
having the folder separated like you do is a step in the right direction. next step is to configure IIS to point to that separate folder. then you would need to create a DNS entry for your sub-domain at your DNS host. "subdomain.domain.com". You would be creating a new site, so you could use the same IP address, as long as you add the proper host headers for each site.

Wordpress development - local and remote paths

I'm trying to set up wordpress so that relative paths work on both my localhost development and my live site.
I was hoping it was just a matter of changing the "site" URL and "home" URL to http://localhost/ and www.example.com, and then links would be relative. However this is not the case, and I think .htaccess complicates the issue.
Eg, if I want to access a file in www.example.com/wp-content/mydirectory I can do this:
$url = '/wp-content/mydirectory/myfile.php'
but on my local site I have to do this:
$url= '/www.example.com/wp-content/mydirectory/myfile.php'
I have a solution by conditionally echoing a var at the start of the path, but it's not always possible to use PHP to accomplish this, for example, in a post or page where the link is in the content.
Does anyone have an elegant solution?
Go to the database and look inside the config table. There's a value for home (and possibly another value called URL, the table is not too big, so give it a quick scan), change that to your local environment for testing and when you're ready, you can change the record in the database and upload to your remote server.

Resources