Even though GoDaddy supports mod_rewrite, there are some definite peculiarities about their setup, with regards to .htaccess and PHP execution. Hopefully the observations I've made in this article will be of help if you're coming across the same problems I was.
UPDATE [9/Jul/2006]: .htaccess changes seem to be taking effect immediately now, at least for me.
UPDATE [3/Dec/2007]: According to comments left below, this is still an issue. I can't verify, though, as I stopped using GoDaddy ages ago. I've restored the stricken text, but please don't assume this information is still correct, as Your Mileage May Vary.
I was trying to set up Nucleus CMS and was having a little trouble with setting up the whole permalink / fancy URLs thing. In particular, the mod_rewrite stuff in .htaccess didn't seem to be working correctly.
Googling for htaccess rewriterule godaddy tells me that I'm not the only one who was having issues.
I managed to get it working, and there are a few things to note:
- Changes to the .htaccess file DO NOT TAKE IMMEDIATE EFFECT: I got very frustrated whem my rules were seemingly ignored, until I noticed that rules I deleted still worked. So, after making a cup of tea, I came back to find they all worked. I'm pretty sure this is the problem most people are having.
- Requests for PHP files (eg. http://gidden.net/tom/item.php) are intercepted well before .htaccess (and definitely mod_rewrite) activate. So, mod_rewrite will not work on URLs for PHP files.
- However, it will allow redirections to PHP files.
Like many of GoDaddy's services, the changes aren't instant: when you change a setting in the hosting manager, it often takes 10-15 minutes to happen. At one extreme, I moved the hosting package to another (non-existent) domain while shuffling things around, and it took 24 hours before it would let me change it back.
I think they must have a weird form of file distribution where the FTP servers are not talking to the same filesystem as the webservers, and a cron job performs some sort of mirroring. Either that, or there's some caching that doesn't get cleared correctly.
The fact that PHP files bypass .htaccess makes me think that PHP requests are separated out (possibly by some load-balancer or other magic box) and run on a different server. It's clear that PHP is run through the CGI/FastCGI mechanism, rather than the more usual mod_php/apache way, but I wouldn't necessarily expect a large-scale shared hosting site to use mod_php. It's a slight inconvenience, but understandable.
So, back to the Nucleus configuration. The "normal" way of doing fancyurls (using FilesMatch and ForceType magic) doesn't work on GoDaddy, since the PHP execution mechanism is long gone by the time Apache reaches the .htaccess file and ForceType. The alternative way listed in the documentation that uses mod_rewrite seems inadequate: it doesn't use the "Fancy URLs" mechanism in Nucleus, and the URLs really do feel less fancy as a result. Now that mod_rewrite seems to work correctly, we can use it to implement the extra/fancyurls files in a better way. I configured .htaccess as follows:
Options FollowSymLinks RewriteEngine On RewriteRule ^member/(.*) index.php?arr=member/$1 RewriteRule ^item/(.*) index.php?arr=item/$1 RewriteRule ^category/(.*) index.php?arr=category/$1 RewriteRule ^blog/(.*) index.php?arr=blog/$1 RewriteRule ^archive/(.*) index.php?arr=archive/$1 RewriteRule ^archives/(.*) index.php?arr=archives/$1
...and then changed index.php to sort this out in a big switch statement before handing over to selector().
There are other improvements to make, but I've now moved to WordPress instead. The WordPress permalink configuration seems to work fine, although as with Nucleus CMS it takes a few minutes for GoDaddy's servers to notice the changed .htaccess file.
Thanks Tom,
I was facing this trouble from last few weeks and was unable to configure it out. but now mod_rewrite on godaddy works perfect for me.
I still have to wait a few minutes for .htaccess to take effect on GoDaddy. One of those aggravating occasions where a computer problem mysteriously fixes itself given time.
Hi,
I have to redirect a url on godaddy web hosting serer. but it is not happening.
www.test.com/test/abc then it should be changed into
www.test.com/test.php?param=abc
Reply
Thanks
It should be something like:
RewriteEngine On
RewriteRule ^test/(.*) test.php?param=$1
in /.htaccess
I did something with godaddy, its not pretty but it works for permalinks etc.
First you create a page:
http://whateverdomain.com/com/content.php?page=events&id=101
where the page is made up of content dynamically taken from a database using the two parameters passed in the URL (page and id)
Set your .htaccess file to show
redirectmatch 301 ^/content/(.*)$ /content.php
RewriteEngine On
RewriteRule ^content/(.*) /content.php?var=$1
I used the info above that
\"Requests for PHP files (eg. http://gidden.net/tom/item.php) are intercepted well before .htaccess (and definitely mod_rewrite) activate. So, mod_rewrite will not work on URLs for PHP files.
# However, it will allow redirections to PHP files.\"
So I made up a fake, non php file and url containing the two parameters that I needed i.e.
http://whateverdomain.com/content/events/101/index.asp
which will then redirect to:
http://whateverdomain.com/content.php?var=events/101/index.asp
A little php on the content.php:
$data = explode(\"/\",$_GET[\'var\']);
$page = $data[0];
$id = $data[1];
And everything works beautifully. Very awkward, but it works.
Hope this helps!
I want to do same thing
www.test.com/test/abc to
www.test.com/test.php?param=abc
On my hosting directory my site is not hosted on root, but it is hosted at in a directory in root say xyz
So when I write in my .htaccess-
RewriteEngine On
RewriteRule ^test/(.*) test.php?param=$1
now when I use your method and write url -
www.test.com/test/abc
it gave 404 error -
The requested URL /xyz/test.php was not found on this server.
How should I change the .htaccess file ?
is the .htaccess file on the test/ directory?
Email me the full htaccess file info dave dot allen (at symbol) shaw dot ca
You may need to add
redirectmatch 301 ^/test/(.*)$ /test.php
Thanks for your answers, Dave... I stopped using GoDaddy a long time ago, so I can\'t really help on this issue.
Their modifications, such as grabbing PHP out in the early stages of the request, make debugging .htaccess behaviour fairly tricky, so it\'s difficult to guess what\'s going to happen.
Plus, the fact that rewrite rules can be fairly tricky on their own!
Tom, thanks for this post. I do want to post here that I just pulled my hair out uploading, deleting, reuploading, uploading through FTP, uploading through the Account Manager at GoDaddy, uploading in binary, reuploading in ascii... then I found this post.
Even though the strikethroughs indicate the delay issue was fixed, it currently isn\'t. I waited 5 minutes, and poof! Worked like it\'s supposed to.
So, hopefully this little addition will let other poor souls know to wait just a bit and stop screaming at your poor htaccess file.
Jim
http://www.findmytee.com
Thanks for the notice, Jim, and the other commenters that highlighted this. I\'ve removed the strikethroughs accordingly.
My godaddy account had multiviews turned on which do some \"smart rewriting\" of their own before mod_rewrite does...which causes problems. After turning off multiviews, all my old mod_rewrite stuff worked again. To turn off multiviews add this to your htaccess file:
Options -MultiViews
I wrote a little more about it on my bog:
http://www.btjones.com/2007/12/09/godaddy-mod_rewrite-problem-fix/
I am soooo glad I found your article, just in the nick of time. I was just getting ready to call GoDaddy for another slugfest over access rights, when I read your article reminding me that nothing happens fast with this hosting. By the time I got done with your article, my rewrites were working. Best thing that could have happened. I\'m sure they would have sat on the phone with me getting every page to redirect needlessly and killing my seo attempt in the process.
I’m using the GoDaddy shared Linux plan and my .htaccess file isn’t working. Maybe their configuration has been changed. I want URLs that begin with http://mikeskramstad.com to redirect to the “www” version. Here’s the code:
RewriteEngine on
Options -MultiViews FollowSymLinks
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.mikeskramstad.com$ [NC]
RewriteRule ^(.*)$ http://www.mikeskramstad.com/$1 [R=301,L]
I had the problem on a GoDaddy virtual server. I read your article and was convinced there would definitely be a solution for my Drupal \'clean directorie names\'.
I noticed that although the rewrite rule didn\'t do as expected on:
http://www.myvirtualdomain.com/
it actually did work on:
http://mymastergodaddydomain.com/myvirtualdomainpath/
So I knew i was a path related problem. My solution was to change:
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
to:
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
(notice the extra / to distinguish the path correctly)
This stopped it from working in my 2nd example (as expected) but made it work correctly for where it mattered on:
http://www.myvirtualdomain.com/
Alternatively, it was discovered that I could add:
RewriteBase /
and leave the initial RewriteRule
In any event the secret to making it work is to experiment.
I\'ve also noticed that sometimes the change takes affect immediately and on other occassions I\'ve had to wait several minutes.
I really appreciate this article. In trying to figure out why my .htaccess rewrites were not working I came across this article. However, I am still going to move my sites to another host. GoDaddy does not allow external database connections, nor can I find any way to setup a cron.
I have been trying to get SEF working on a shared Go Daddy website for 3 days with no luck until a few minutes ago. I have read and read and read... Okay, here\'s what seemed to work. Here\'s the a quick background: First, I did input the line, \"Options -MultiViews\" into .htaccess as mentioned above. Secondly, I uncommented the line \"RewriteBase /\" which several people say to do. Thirdly, since my Joomla 1.5.2 websites (using PHP 5.2.5) are each in a subdomain of my root folder (my root is for a regular HTML website) I added in a duplicate copy of .htaccess into the root folder. Okay, so: having done those three things still nothing worked.
Then, a few minutes ago, I tried it again, but this time I made one change and voila, the whole thing WORKED. Here\'s what I did:
Each time I\'ve made a modification to the \".htaccess\" file I did it in a certain way that seems to have been the problem. To elaborate: I copied it over to my hard drive using Filezilla, then changed the name to \"htaccess.txt\". Then, in Dreamweaver, I\'ve gone into the file and made whatever change. Then, back in Filezilla, I uploaded the new \"htaccess.txt\" file onto the website, THEN lastly, I changed the name back to \".htaccess\". That seems to have been the problem. This never worked.
A few minutes ago, by a fluke, I instead changed the name BEFORE I uploaded the file onto the website. And that worked. Everything worked immediately. On two different websites.
I\'m basically a newbie, so any old-timers are probably reading this and groaning... I hope not. But just in case, this is what seemed to work, finally, for me.
Take away: Try this: to change the name of \"htaccess.txt\", upload the file using Filezilla onto your hard drive, then change the name of the file while it\'s on your hard drive (you can do this while still in Filezilla). Then upload the newly renamed file \".htaccess\" back onto the server. Go into your Global Config and turn on SEF and mod_rewrite and see if it works. Good luck!
thank you so much! Rock on!
I have a multi-site hosted on godaddy with the root directory hosting one site and /hindupedia hosting another site (which is reached by the url: www.hindupedia.com). After trying alot of things on the web, I finally found a way to make this work.
here is my .htaccess file\'s contents
AddHandler x-httpd-php5 .php
AddHandler x-httpd-php .php4
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^hindupedia/eng/(.*)$ en/index.php?title=$1 [PT,L,QSA]
We\'re having a devil of a time launching our site on GoDaddy hosting. We\'ve been running on an off shore hosting environment for a while and now have made the decision to move to GoDaddy to consolidate with my domain registrations, etc. Our .htaccess file worked perfectly in the old hosting setup but was running under PHP ver 4.
We\'ve updated the .htaccess to instruct the support for ver 5 and still no joy. Our current version of .htaccess includes the following:
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
order deny,allow
deny from all
allow from all
order deny,allow
deny from all
AuthName www.wine-hotels.com
AddHandler x-httpd-php5 .php
AddHandler x-httpd-php .php4
AddHandler server-parsed .php .html
# Enable rewrite engine
RewriteEngine On
Anybody have any ideas how to get this to work in GoDaddy?
Thanks in advance.
Hey Tom,
I hope this note finds you well. Back in September, you were kind enough to help me through some trouble I was having with a .htaccess file on my GoDaddy hosting servers. We sorted through this issue, but we are now experiencing some more problems when trying to launch the site with some new enhancements. I\'ve pasted the text from our .htaccess file below. My developer tells me we need to enable the mod_rewrite and set as LoadModule rewrite_module modules/mod_rewrite.so in httpd.conf file. I thought GoDaddy set the mod_rewrite by default? Anyways, can you take a look at the .htaccess below and let me know if you see any issues? Thanks a million in advance.
Jeff
---------------BEGIN .HTACCESS
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
AddHandler x-httpd-php5 .php .html
AddHandler x-httpd-php .php4 .html
order deny,allow
deny from all
allow from all
order deny,allow
deny from all
AuthName www.wine-hotels.com
# Enable rewrite engine
RewriteEngine On
RewriteRule ^index.html web/index.php [L]
RewriteRule ^([^/]+)/index.html web/home.php?rname=$1 [L]
RewriteRule ^([^/]+)/hotels/index.html web/list.php?rname=$1&catid=1 [L]
RewriteRule ^([^/]+)/restaurants/index.html web/list.php?rname=$1&catid=2 [L]
RewriteRule ^([^/]+)/wineries/index.html web/list.php?rname=$1&catid=3 [L]
RewriteRule ^([^/]+)/activities/index.html web/list.php?rname=$1&catid=4 [L]
#RewriteRule ^([^/]+)/hotels/map/(.*).html web/map.php?rname=$1&catid=1&name=$2 [L]
#RewriteRule ^([^/]+)/restaurants/map/(.+?).html web/map.php?rname=$1&catid=2&name=$2 [L]
#RewriteRule ^([^/]+)/wineries/map/(.+?).html web/map.php?rname=$1&catid=3&name=$2 [L]
#RewriteRule ^([^/]+)/activities/map/(.+?).html web/map.php?rname=$1&catid=4&name=$2 [L]
#RewriteRule ^([^/]+)/hotels/phototour/(.*).html web/phototour.php?rname=$1&catid=1&name=$2 [L]
#RewriteRule ^([^/]+)/restaurants/phototour/(.+?).html web/phototour.php?rname=$1&catid=2&name=$2 [L]
#RewriteRule ^([^/]+)/wineries/phototour/(.+?).html web/phototour.php?rname=$1&catid=3&name=$2 [L]
#RewriteRule ^([^/]+)/activities/phototour/(.+?).html web/phototour.php?rname=$1&catid=4&name=$2 [L]
#RewriteRule ^([^/]+)/hotels/(.+?).html web/detail.php?rname=$1&catid=1&name=$2 [L]
#RewriteRule ^([^/]+)/restaurants/(.+?).html web/detail.php?rname=$1&catid=2&name=$2 [L]
#RewriteRule ^([^/]+)/wineries/(.+?).html web/detail.php?rname=$1&catid=3&name=$2 [L]
#RewriteRule ^([^/]+)/activities/(.+?).html web/detail.php?rname=$1&catid=4&name=$2 [L]
krishna - thank the lord : )
your advice worked out just right ;
added
AddHandler x-httpd-php5 .php
AddHandler x-httpd-php .php4
Options -MultiViews
and things started working immediately for me : )
Thanks for the page tom, it shows up first at google for mod_rewrite and godaddy.com
PS; My .htaccess
AddHandler x-httpd-php5 .php
AddHandler x-httpd-php .php4
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Maybe someone can help me with this.
My Joomla site is hosted on GoDaddy. I want the homepage to be www.mypage.com/index.html, a portal page which will display several links, one of which will go to www.mypage.com/index.php
The action of putting \"Directoryindex index.html index.php\" only makes the site go to index.html when www.mypage.com OR www.mypage.com/index.php is clicked or put into the browser.
Any ideas?
Yeah, I encountered many of the same problems you describe here. I was setting up WordPress 2.7 on Godaddy\'s Economy Hosting, and was never able to confirm that mod_rewrite actually is supported (I tried waiting hours to see if it worked, but no luck). Eventually I found a brilliant workaround using a custom 404 file, which I point to via the Godaddy admin. I wrote about it here: http://ferrogate.com/2009/04/the-new-ferrogate-i-moved-from-blogger-to-wordpress.html .
Thanks for a great blog, subscribing to it as we speak.
Dude! fckn\' amazing it worked
thank you Spell
Spell Wrote
\" I have been trying to get SEF working on a shared Go Daddy website for 3 days with no luck until a few minutes ago. I have read and read and read... Okay, here\'s what seemed to work. Here\'s the a quick background:...\"
Options FollowSymLinks
works like a charm for those who have problem with htaccess in GODADDY servers
has anyone got any experience with installing JuxtaPhoto on godaddy.
The issue seems to be this mod_rewrite, but have not been able to solve it.
Guidance would be greatly appreciated.
Thanks in advance.
I have a godaddy hosting account on shared linux server and was having the same problem as lot of you. I started off with using:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
I wanted to remove my file extensions using:
RewriteRule ^(.*)$ $1.php [L]
All logic should state that it should work! I\'ve been playing around and discovered that:
RewriteRule ^folder/page$ /folder/page.php [L]
will not work!!! But if I add any character onto the end of page such as a \'d\' or \'s\' it works!
RewriteRule ^folder/paged$ /folder/page.php [L]
Finally, in order to make it work Options +FollowSymLinks must be changed to Options -MultiViews. Anything else and it will not work.
Gman
To enable on godaddy, I found out the hard way, you must include \"RewriteBase /\" whereas on my local drive, this was not necessary.
RewriteEngine On
RewriteBase /
Thanks SO much! Your method works perfectly for me. I am able to list every entry as you did in your example.
Here\'s my file(it hides html, png, jpg, and specific php extensions):
Options FollowSymLinks
RewriteEngine On
RewriteRule ^example(.*) example.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.jpg -f
RewriteRule ^(.*)$ $1.jpg
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.png -f
RewriteRule ^(.*)$ $1.png
I have been reading through all of this and it seems as though many of you have figured out how to create a functional .htaccess file on go daddy. I am looking for an .htaccess file that will allow me to use php rss feeds in my html site so that I can use a feed to display my blog and facebook page. Can anyone give me an example that I can just save and adjust with some explanation in lamens terms?
Now years later from original post..I set up URL rewriting on my Drupal site on Godaddy some months ago and it was working..today it was broken (http error 500). I had not changed anything. The problem appeared to be that I had:
RewriteEngine On
Options All
I changed that to
RewriteEngine On
Option +FollowSymLinks
Support may not know about this, but it seems one
cannot use Options All on that host