Support

Site Restoration

#26603 Copying Wordpress site to new

Posted in ‘Site restoration’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

PHP version
n/a
CMS Type
Other
CMS Version
n/a
Backup Tool Version
n/a
Kickstart version
n/a

Latest post by on Saturday, 31 December 2016 17:17 CST

webcoast
Hi,
I am just trying working with Wordpress for the first time (lots of experience with restoring Joomla websites using Akeeba and Kickstart) and am having strange problems with the newly restored site.

I am restoring into a sub directory. The main site is in public_html/ and the restored site is in public_html/temp
http://webcoasthost3.com/temp/

The kickstart process runs smoothly, but I am wondering whether it is something to do with the "replacements" part of the process, because the issue is that the home page is displayed without styling, and the links to the other pages all have too many occurances of /temp in them. For example, instead of being webcoasthost3.com/temp/about-us it is referring to webcoasthost3.com/temp/temp/temp/about-us

I also have no access to the backend, as it webcoasthost3.com/temp/wp-login.php redirects to http://webcoasthost3.com/temp/temp/temp/wp-login.php and this shows the blog page.

I have copied sites to sub-directories lots and lots of times with Joomla, without issues. Can you not do the same with Wordpress?
Thanks, Nicola

nicholas
Akeeba Staff
Manager
Joomla never stores absolute URLs. All of the URLs it stores are relative to the home page. Furthermore, Joomla never stores absolute filesystem paths. It always stores paths relative to the site's root. This lets Joomla be transferred to subdirectories, subdomains, new domains and different servers without a problem.

WordPress, on the other hand, still lives in 1998. They store absolute URLs and filesystem paths. Even worse, these absolute references are inside data serialized with PHP's serialize function. Due to its nature you can't simply unserialize this data and replace the references. Unserializing the data requires running inside WordPress and, in fact, having loaded the exact plugin which has generated the data. However you can neither run WordPress before you replace the absolute URLs and file system paths (therefore creating a chicken and egg issue!), nor do you have any programmaticaly useful indication of which plugin generated which data. Therefore WordPress, as it stands, cannot be transferred to a new directory, subdomain, domain or server without external help.

The WordPress Plugin Directory has several tools which purportedly help with that. However, they really don't. They all use regular expressions which work in some cases but not all. All of them invariably end up with corrupting some data in your database, losing you some functionality of your site, or worse. We solved this problem by writing our own tokenizer for serialized PHP data, allowing us to perform an accurate data replacement in serialized data. That's what is being used in the data replacement step. This is what we're doing to help you transfer a WordPress site just like you would with a Joomla site, a feature not present in any of the other backup software for WordPress.

However, a site is NOT just files and database data. It runs through a web server (Apache). WordPress, like Joomla, needs to use SEF (fancy) URLs like /foo/bar instead of unsightly non-SEF URLs like index.php?some=1&thing=2&or=another. But PHP only works with the latter. Therefore you need to have a transformation of the former to the latter. This is where the .htaccess file comes into play. It tells Apache how to handle URLs that it would otherwise not be able to figure out how to route through the index.php file of the site.

WordPress being an unnecessarily complicated beast it stores the relative folder path of its installation inside the .htaccess file. We do try to replace that too during the data replacement step, but there are a few limitations. The .htaccess file is not so much of a configuration file as a programming language. As you understand, it's not possible for a computer to accurately figure out the intent of free form text -be it prose, verse or programming language- and perform operations based on intent. Therefore we have to resort to making assumptions and educated guesses. All of that goes out of the window when you try to transfer a site from the subdomain's or domain's root to a subdirectory for two reasons:
  • The subdomain's or domain's root relative path is denoted with a forward slash: / This is just as a non-specific target for data replacement in the .htaccess as anything you may find.
  • .htaccess files cascade. Therefore the main site's .htaccess is parsed BEFORE the one in the "temp" directory and they are both merged and executed. This ALWAYS causes problems with SEF URLs. This is not specific to WordPress, it also happens to Joomla and we do warn you to never do that.


TL;DR. There is an easy way out

As we've been saying to our Joomla clients for a decade, do not use subdirectories of your main site to create temporary / dev sites. Instead, create a subdomain.

Danger, Will Robinson! When you are creating a subdomain the default behavior of cPanel is to create a subdirectory inside public_html. You do not want that! The correct approach is to go to cPanel's File Manager first and create a new directory temp_html next to (not inside of) public_html. Then go ahead and create the subdomain. cPanel will ask you where to store the subdomain's files. Choose the temp_html directory you had created.

Now you can restore your site in the subdomain you created and you will no longer have any pesky .htaccess problems causing the directory to appear twice in the URLs :)

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

webcoast
Hi Nicholas, sorry it has taken me so many days to reply, this first Wordpress site is relegated to 'spare time'.

Firstly I have to say a sincere thank you for your excellent (once again) reply to my ticket. I think this reply is probably THE best support reply I have ever had. Why? Because you compared Joomla (which I am very familiar with use Akeeba and Kickstart with) to Wordpress, and explained the difference in absolute/relative URLs. Not only that, but then you told me WHAT I needed to do to get around the problem, and PITFALLS to watch out for. That's outstanding service, you've saved me a whole lot of time and I thank you for that.

I also wasn't aware of the directories issue with Joomla, so I will be mindful of that in the future.

Now I just need to squeeze in some time to go and try it!
Thanks again.
Nicola

nicholas
Akeeba Staff
Manager
You're welcome and thank you very much for your kind words :)

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

System Task
system
This ticket has been automatically closed. All tickets which have been inactive for a long time are automatically closed. If you believe that this ticket was closed in error, please contact us.

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!