Tuesday, August 13, 2013

Making the Website Domain Show the WordPress Page

I try to force myself to do what appears to be hard as the first project I attack in the day. To date, I have registered a new domain for my school, found and installed a WordPress theme, and customized the information. When I typed the domain name http://www.smscranford.com into the browser the HostGator temporary screen appeared. I had to type http://www.smscranford.com/wp to see the school page. I was ready to make the main domain display the WordPress page.

Google Search
I performed a search to redirect domain to WordPress home page and found the following page as a result: http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory . This set of directions was fairly simple to follow. I wanted to document the steps with images.

I knew that I did not want to move the entire WordPress installation to a new directory so I followed the steps for Using a pre-existing subdirectory install. I am using HostGator so the commands may look a little different for other domain hosting companies. The CPANEL for HostGator does look like the one I am used to for A2 Hosting and others I have seen.

Steps 1-3 are completed in WordPress. I had to go to the WordPress General Settings section. Initially the WordPress Address (URL) and Site Address (URL) were the same.

I changed the Site Address (URL) to http://smscranford.com. Step 3 does say not to worry about errors or try to see the domain at this point. I did look and got an error message. Step 4 fixes those problems.

Be Smart Backup or Rename Files
From many years of working with computers, I knew that I needed to make sure I could easily undo anything I did that would completely destroy the website. It was better seeing the HostGator temporary home page than trying to undo damage on my own.

In the CPANEL for my HostGator account I scrolled down to the Files section and chose the File Manager icon.

If you are at all familiar with working with copying and pasting files on a PC, Mac, or other computer you will be comfortable with the following steps.

Step 4 in the WordPress directions that I was following says to copy NOT move the index.php and .htaccess files from the WordPress directory to the root directory of the website. Clicking the File Manager icon brought up a window.

I knew the main files were in the Web Root (public_html/www) because from past experience I had installed index.html in that directory, public means the world can see it, HTML is the basis for web pages, www is world wide web files. The directions in step 4 noted that I might need to look at hidden files, so I made sure to check the Show Hidden Files check box.

On the left side of the screen are a list of all the subfolders for the entire website domain. I was viewing the entries in public_html/www. In addition to the cgi_bin and wp folders were a few files:

Since I would be replacing .htaccess and index.php I decided to rename them. In this
way, if anything looked really bad I would just rename them back to the original names and it would be as if nothing ever changed. To rename the file, I clicked the file name (for example htaccess) and at the top of the screen I found and clicked the Rename icon.

It was handy to have some facility with website domain file names. There was not an existing index.php file. It was originally named default.html. I renamed the file with the word old following the period. So .htaccess became .oldhtaccess and default.html became default.oldhtml.

Next I double clicked the wp folder in the directory. I located the index.php file and chose the Copy icon at the top of the screen and changed the entry at the bottom of the Copy box from /public_html/wp to /public_html. I did the same for the .htaccess file. When I tested www.smscranford.com, I still did not get the right page to display but confidently moved on to step 5.

As I read step 5 my confidence sunk a bit for a minute. It said I was going to have to use a text editor to change the index.php file in the root directory. I went back to the public_html folder clicked on index.php and noticed two icons at the top of the screen. One said Edit and one said Code Editor. I decided to try Edit. It gave me a slightly disconcerting message that said I could cause many problems by editing the file but decided that the worst that would happen would be that I would need to delete the file and copy it again from the WordPress directory. When I clicked Edit, my confidence returned again.

The php file looked a lot like HTML. Step 5 said to change the require('./wp-blog-header.php'); to the folder that contained my WordPress files. I knew my WordPress folder was wp so I changed the line to require('./wp/wp-blog-header.php'); and clicked the Save Changes button in the upper right corner of the screen.

This time, when I typed www.smscranford.com I received the new web site's correct home page! I did not need steps 6 or 7 since I did not set any Permalinks for the school website.

Doing the Hard Things First Makes Sense
It actually took longer to document this than to actually perform all the steps the first time. I always like to document things here in my blog. Someday I will want to do this again and I won't have to reinvent the wheel.

No comments:

Post a Comment