Redirect With .htaccess and Godaddy Hosting Not Working – Solution

Goddady Server Redirect

For something that seems so simple, there’s a lot that can go wrong with setting up either a temporary (302) redirect or permanent (301) redirect. With Godaddy hosting specifically, you may run into an issue that you did not foresee. You may even have no trouble redirecting the ENTIRE site, but to redirect just the home page you may encounter some issues.

Note, if it seems like your .htaccess files almost never work for your WordPress site, you may have a different issue.

Let’s do an example of a temporary redirect using an .htaccess file on a linux hosting server. The following is what you might see as a generic example people use to show you what to put in there. We want to redirect our homepage to example.com. In this particular example, in theory this SHOULD redirect our homepage (even if the home page file itself is not actually named index.html) to this new url.

You’ve got all this set up and yet… Nothing happens when you go to the home page. So what’s the problem?

 

Tired of dealing with your slow WordPress website? Email me at brian@pagecrafter.com and mention the code #FreeHosting10 for two free months of lightning-fast WordPress hosting. We will even migrate you for free!

Why your .htaccess redirect isn’t working

This actually applies to hosts other than Godaddy as well. The secret is this: the relative location of your index.html is relative to the root of your server. NOT the root of your website.

I know what you are thinking, “but those are one and the same!” Not so fast, jerk. Are you SURE they are the same? If you are hosting more than one website in the same hosting account, you are almost definitely wrong. And even if you aren’t, you still are probably wrong. In my case, the proper line in my .htaccess file is:

In this case I’m not hosting this particular website in the root of my hosting account, it’s a subfolder named “mywebsitedotcom”. You may have something like that. Or it may be something like “httpdocs” or “public_html” or something along those lines. The only way to know for sure is to connect to your server via ftp (either a normal ftp client or an online one built-in to your hosting account) without specifying a subfolder, and seeing where you put your website. Once you know that, you just have to drill down to it in your redirect declaration in the .htaccess file. Problem solved!

You may have also run into issues where a redirect of yours ends up including the path directory in the new page, even though it really shouldn’t be. It tends to be a similar issue! Check out my other blog post on redirecting one file extension to another for more on that.

If you need additional help, email me at brian@pagecrafter.com or tweet me @brianjonline. Good luck!

About Brian Johnson

Brian Johnson is a website developer and designer living in Minneapolis, Minnesota with a passion for code and WordPress. He spends his days building WordPress websites for small businesses, developing new code with the online community, and living life.