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.
1 |
redirect 302 /index.html http://example.com |
You’ve got all this set up and yet… Nothing happens when you go to the home page. So what’s the problem?
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:
1 |
redirect 302 /mywebsitedotcom/index.html http://example.com |
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!
24 Comments on “Redirect With .htaccess and Godaddy Hosting Not Working – Solution”
Hi Brian!
I found this while searching a solution for an Internal server error on http://christopherjose.com/this-is-a-test-blog
My host is Godaddy and the .htaccess is as follows:
RewriteEngine On
RewriteBase /christopherjose.com/
It works perfectly on Xampp server whereas on godaddy the address I’ve specified ‘christopherjose.com which is a sub folder as you have mentioned in your article.
Still error occurs.
Have shared hosting plan at godaddy. Each domain name has a folder name. When redirecting from http to https Godaddy’s code they give and others works fine when typing in example.com or http://www.example.com. Goes right to https.
When I type in a browser address bar, with cache cleared, or click my website link on the web it adds the folder name to the URL.
For example… I type in http://www.example.com/contact.htm in a browser the link goes to http://www.example.com/GodaddyFolderName/contact.htm and the link doesn’t work.
This folder name is becoming part of the URL when I type it in a browser. If someone could provide the .htaccess code I would be forever in you debt.
Folks, I need help. I am new at this. My site was working. A friend I am working with sent me a new tar file with an index.html page, a static folder with js, css, and img. I uploaded the new stuff, but the site is not displaying. I have a small start-up, traffic on the site had started to grow. But I am now stuck. My colleague is in Germany, this is a side thing we are trying to start.. Sorry if I am jumping all over the place.. Any help out there?
Looks to me like you have some DNS issues! You’ll want to make sure your domain is configured to actually get hosted somewhere. Right now there is no DNS address listed!
Thank you so much! You just made my day after hours of troubleshooting!
Brian, you are the man. I just wasted many hours trying to figure out why my site was not redirecting. 4 Godaddy reps later and still no solution. Nobody knew that it was because the redirects were being placed in my root directory rather than the website directory… seems elementary to me (If I was a support rep). In any event, thanks dude. High five.
Glad I could help! 🙂
Hi, can somebody tell me if this GoDaddy’s advice in my web page is related about the htaccess problem with WordPress? Thank you. Attached img of the problem (deleted)
I very much doubt it’s related to an htaccess issue. I would say that you either have not uploaded your site to the appropriate folder in your hosting yet, or you may want to try deleting any html files that might be responsible for that page. It’s also possible that you haven’t assigned a folder to that website yet! Either way, Godaddy support should be able to help you out.
Is it correct……
RewriteEngine On
RewriteCond %{HTTP_HOST} ^brother.printersupportaustralia.net$ [NC]
RewriteRule ^(.*)$ brother.printersupportaustralia.net/$1 [R=301,L]
It doesn’t look like that works, no! I’m not an expert at troubleshooting individual rules though; regular expressions are hard! Use this site to test though: http://htaccess.mwl.be/
I couldn’t figure out why the redirects worked sometimes and not others and then it hit me: It’s GoDaddy! I use Bluehost for some websites but some are in GoDaddy. Once I figured out that there was something different about how redirecting with them, I then went looking in their documentation for the answer. Along the way, I found your page. Thanks!
THANK YOU!! Trying to clean up a client’s old site creating a couple of 301 redirects and just added them through GoCrappy’s quick “url redirect” option. It didn’t take into consideration that the file had an html extension. Fixed it in the htacess doc and good to go. Cheers!
Perfect! Great advice and it worked for me. Thank you.
I built a wordpress site in a subdomain using godaddy and thought I should be able to just redirect to that subdomain with the root url but it is not working? Do you have any thoughts on that?? Thanks for the article
That should be easily doable. Sounds like something you should call Godaddy support about. Or just follow along on their article: http://support.godaddy.com/help/article/422/forwarding-or-masking-your-domain-name?pc_split_value=1
Thanks so much for taking the time to help others! May you be well and happy, Bob
my htaccess file is in httpdocs but still its not working
The location of the .htaccess file is usually not the problem. It should be located wherever the root of your site is, though honestly I don’t think it matters.
The problem that this article addresses is the fact that the url for the file you wish to redirect is often not what you think it is. For example, in your case, instead of just “index.htm” it may very well be “httpdocs/index.htm” or even “httpdocs/mywebsitefolder/index.htm” or something similar. It goes from the web root of your account, you may need to speak with your host to figure out exactly what that would be.
Hi Brian, Thanks for posting this. I’ve been struggling with redirects on GoDaddy for a few months, eventually fixing many of them with the old file names containing redirects to the new files. The redirects broke all at once and I couldn’t figure out what caused it, but it was likely a change at GoDaddy that took place last year. In my case, I had one redirect from the upper level domain (under which all the other domains sit below), and in that case I had to use the complete file name starting from the root folder of the server. In the case of the subdomains, I used the technique you described, i.e., including the folder name in the redirect which fixed them all. Thank you!
the relative path makes sense but what if there are a number of domains hosted on the same account and the one you want to redirect from is not the primary domain on the hosting account? how would the path look?
subfolderinrootwheredomainispointed/domainname.com/websitefolder/webpage.html
The example given in this tutorial is exactly that situation. The subfolder “mywebsitedotcom” is for a domain in the larger hosting account. That folder name is whatever you’ve chosen for it when you set it up.
i was just about ready to give up until i came to your tip: “the relative location of your index.html is relative to the root of your server. NOT the root of your website.”
that worked perfectly. i can’t believe godaddy’s documenation didn’t stress this.
thank you, thank you!
Pingback: How to Import and Export a Wordpress Database with Godaddy Properly: Tutorial Brian Johnson's Design Blog