↓ Archives ↓

Wordpress blog URL change

Just yesterday I've changed my blog hosting from CirtexHosting to HostMonster. I've used CirtexHosting for 2 years and HostMonster for more than a year, mainly for development purposes. So perhaps, within a few days, I'll post a review about their performance. In short, both of them provide very good web hosting services. However, this post is not about the review, it's about the temporary problem I've faced while shifting this blog hosting.

Problem Description: After you transfer your WordPress blog files from one hosting to another (or perhaps to your PC), initially you'll not be able to access your blog, until you point your previous domain to the new hosting DNS. But, before you change this DNS entry of your blog domain (in my case www.fayazmiraz.com), you may want to (and should) confirm that your new installation is working properly. For that, you'll need a temporary URL to work with your blog, for example: http://localhost/fayazmiraz/. However, according to WordPress setting, this will not work.

Solution: Since I've worked with WordPress before, I already knew a possible solution by making some changes in SQL. Still, I've Googled the problem to find the best solution, since changing SQL sometimes can be dangerous. So, if you have WordPress 2.2 or higher, then here is the best solution for you (Changing your WordPress Blog URL without using any SQL query, by hard-coding the url in wp-config.php):

Add the following lines to your wp-config.php:
define('WP_HOME', 'http://localhost/fayazmiraz');
define('WP_SITEURL', 'http://localhost/fayazmiraz');

[Note: replace 'http://localhost/fayazmiraz/' with your preferred temporary URL]

Now, your WordPress Blog will be working with your new hardcoded Temporary/Permanent URL. In case of Temporary URL, after the testing is complete, delete those two lines and point the DNS entry of your domain to the new hosting DNS. For people familiar with CodeIgniter, this setting is very similar to what you might have done in your CI setting.

More: For more information and other solutions to similar problems (How to change URL), check out the following links:

You can also checkout this Post from CatsWhoCode, if you want to play with the SQL database of your WordPress Blog. But be aware, changes in SQL are irreversible. So do it only if you are absolutely certain about what you are doing.

20 Comments | Pings

  • Mar 15th 201012:03
    by Mahbub

    Reply

    Does this override the settings which is at wp_options table as field name "siteurl".?

    So far i know that you have to change the values for wp_options otherwise all things simply won't work.

    Let me know if putting those two constants do every trick.

    • Mar 15th 201013:03
      by fayazmiraz

      Reply

      Yes, it does. So the only problem is you'll not be able to change Blog URL from "Settings" in Admin panel, since above settings will override them.

      As far as every trick is concerned, it will work only for relative URLs. So if you have any site link hard coded inside your posts, obviously that wont work. In all other cases it will work fine, at least as far as I've tested.

      Oh and it works only for WordPress 2.2 and above.

  • Mar 15th 201013:03
    by paul

    Reply

    gr8, you just saved all the hard work of changing SQL.

  • Mar 30th 201010:03
    by nurul amin russel

    Reply

    just used this - really helpful
    thanks miraz

    • Mar 30th 201010:03
      by fayazmiraz

      Reply

      Russel vai, I actually found this recently, so I thought it'll help others too. Changing WordPress URL was a pain so far, since one needed to change the database entry here and there. So testing in localhost and then moving to the public domain was not as simple as drag and drop.

      Even better news is: after working on it for a while, I actually created an even better way. Hopefully, I'll be able to share it with you soon.

  • Apr 20th 201012:04
    by irvan

    Reply

    Nice, i've moved hosting to hostgator because a lot of spammer that leave tons of spam comment that make Bandwidth Limit Exceeded just in few days.

    but how about import from localhost to public from WP dashboard, have you tried it.

    • Apr 20th 201013:04
      by fayazmiraz

      Reply

      Import works fine, but import has two problems:
      1. If you have many plugins, custom theme and some custom changes in WordPress, then you'll have to do all those changes to your new WordPress instillation in the public domain. So evidently, in some cases you'll forget what change you actually did from the original default setting. So someway, the public version may become different than the local copy. But, transferring all the files using FTP doesn't have the same problem, if you follow my method.

      2. If you have many posts and comments, in other words a very big database, then import may create problems. Otherwise, for small database and default wordpress setting, import is fine.

  • May 14th 201015:05
    by Brooklyn Evans

    Reply

    i host 5 of my blogs on Blogspot and it is really good for beginners. but if you want something with more features, nothing beats wordpress

  • Jun 14th 201016:06
    by Jonathan Rose

    Reply

    Making SQL queries is not that scary. There is a simple online tool to generate sql queries to Change a wordpress URL. There are always a bunch of settings besides the "siteURL" and "home" that you will have to update after the switch - by making these queries you can save yourself a lot of time and headache.

    • Jun 14th 201017:06
      by fayazmiraz

      Reply

      Actually when you transfer your WordPress powered blog, from one domain to another, in that case changing database with SQL queries will not hurt, and it'll also keep your database clean.

      But for temporary URL change or for people with very few knowledge of SQL, this method will be more suitable. For example, in my case, I test my site locally first (in localhost), everytime I install a new plugin, change something in the theme etc.
      Then upload the new files to my site.

      If I used SQL to change site address, then I would have to run the queries every time I make a test. So that's why keeping the url in wp-config helps.

  • Jul 7th 201005:07
    by Justin Sonner

    Reply

    I just had this problem what I did was simply update the to the URL and save settings (which of course takes your site offline). Move it then update your .htacess which if you have moved it from a root to a root of server won't be a problem but if inside a file inside your server root then will.

    • Jul 7th 201013:07
      by fayazmiraz

      Reply

      If you move the site inside a "folder" of your server root, in that case you'll have to update your WordPress .htaccess to make it work correctly:

      .htaccess for root:
      -----------------------
      RewriteEngine On

      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]

      .htaccess for "sub" folder inside root:
      ----------------------------------------------
      RewriteEngine On

      RewriteBase /sub/
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /sub/index.php [L]

  • Aug 3rd 201009:08
    by Jonny

    Reply

    I want to convert my website to WordPress. I have the plugin needed to keep .html on the pages. However, as you can see some pages " http://www.buildgreenenergy.info/Magnetic-Motor.html " have "M" capitalized in URL. I want to save all the new pages in WordPress as they were in the old website with the capital letters. I want to keep all the URLs as they are because of all the backlinks. Do you have any suggestions how to do this? I do not want to use a redirection plugin and change the URLs.
    Thanks!

    • Aug 3rd 201020:08
      by fayazmiraz

      Reply

      Hi Jonny,

      Best way is to hire an expert and let him do the job for you. Since, there might be issues because of your server capabilities etc.

      You can hire them from freelance site like freelancer.com | elance.com etc.

      Still, if you want to do it yourself, you can follow the the instructions below:

      Assuming you have the right .html extension plugin (which should add an additional .html extension after each perma link WordPress generates):

      1. Go to wp-admin -> settings -> Permalinks

      2. Select "Custom Structure" and in the input box type the following:

      /%postname%/
      and save the setting

      3. As you create new post, after providing a post name, you'll see that permalink of that post will appear below the title. Now, set the permalink as you like (without .html of course)

      Upper cases will be converted to lower case, but don't worry, after submitting the post, you should be able to access the post with any "case" you like, since the links are case "insensitive".

      So, you'll still get all the back-links, and search engines will not demote your rating, since search engines also see the links in case insensitive manner.

      Hope, these instructions will help you.

      • Aug 5th 201008:08
        by green energy

        fayazmiraz,

        Interesting that you said "links are case insensitive". I believe anything after the / is case sensitive. Do you have an example of a website that is case insensitive?

        Just as there is a simple plugin for .html ( called .html on PAGES ), I am hoping to find the code or plugin for capital letters in url.

        Jonny

    • Aug 5th 201009:08
      by fayazmiraz

      Reply

      Jonny,

      In Unix, file/folder names are "case sensitive", since most of the time a link (after the /) is also a file in the server, the link also becomes "case sensitive" in case of Unix servers.

      In windows however, file/folder names are "not" case sensitive. So any link that corresponds to a file to a windows server, is "case insensitive".

      Although, the important thing to keep in mind is that, Wordpress posts do not correspond to any original file or folder in the server and Wordpress engine itself considers the post URLs in a "case insensitive" manner.

      For example, my site is in a Linux Server, but it does not have any directory named "wordpress-blog-url-change", this is rather a generated link from wordpress. So although it is in a case sensitive Linux server, you'll be still be able to access this page in different cases; like:

      http://www.fayazmiraz.com/wordpress-blog-url-change/
      or
      http://www.fayazmiraz.com/WordPress-Blog-Url-Change/
      or
      http://www.fayazmiraz.com/wordpreSS-bloG-uRl-chANge/
      etc.

      However, in my server there is a file named: "favicon.ico"
      You can access this icon file from this URL:
      http://www.fayazmiraz.com/favicon.ico
      But, any other case, for example: http://www.fayazmiraz.com/Favicon.ico
      will give you a 404 (not found) error.

      Although, if my site were in a windows server, even the files would be accessible from different cased links. For example, one of my client's site is in a Windows server, and files in that server can be access from different cased links:
      http://www.rossiterandco.com/iMaGes/HEadEr/HoMe_Logo.pNg

      I believe this is enough explanation :) , Thanks.

  • Aug 6th 201010:08
    by green energy

    Reply

    Thank you for the explanation!

    I must be on a unix server (???) since all my websites are case sensitive after the / mark.

    Back to the problem which is http://www.buildgreenenergy.info/ is case sensitive after the / mark and I want to move it to WordPress. Since I cannot find a way to force WordPress to accept capital letters in the url, if I do a 301 redirect, what percentage of backlinks might I lose doing the 301?

    How long until search engines see the 301? (days,weeks or months)?

    Thanks for all the info! It has cleared up my understanding of why some url's are case sensitive and some are not.

    Jonny

    • Aug 6th 201020:08
      by fayazmiraz

      Reply

      @Jonny

      First of all, you'll not need any 301 redirect after converting to WordPress. Even though WordPress forcefully converts all URLs to lower case, the same URLs still correspond to the upper cased version. So even in unix system, after converting to WordPress, your old Upper cased URLs will be accessible. For example, the following two URLs will be the same:

      http://www.buildgreenenergy.info/Magnetic-Motor.html
      http://www.buildgreenenergy.info/magnetic-motor.html

      Secondly, if you still do any 301 redirect, no back-link will fail to do 301. Although you'll have to keep the redirects forever. Since, search engines will correct the URLs, but some other sites (having back-link to your site) will never correct the link. They will always be using the 301 redirects.



  • Pings From:

    » Easier way to change WordPress URL - Dave-Miller.com

    Leave a Reply