I know this issue has been hashed and rehashed in the docs and on the forums, but after reading all that I can't seem to get it. I've got to be doing something wrong. I have a dedicated server on HostGator, who I have never used before now. The apache setup is a little different than what I'm used to, but all the pieces seem to be there. Still, I can't get clean urls to work.

Does anyone have any specific experience with drupal on hostgator servers? Everything is working fine with the install. Well, everything except clean urls. I'm running Drupal 5.5. On my server, I've got a lot of httpd files like:

httpd.conf
httpd.conf.default
httpd.conf.ea-orig
... and a bunch more.

Some of these look like they are auto-generated by WHM, while others look pretty standard. In the past, I have only dealt with one file on the web server, httpd.conf. So maybe the files I've looked in aren't the right ones. No matter what changes I made to something like AllowOverride All (and then restarted apache), I still couldn't get it to work.

Anyone get clean urls to work on a hostgator server?

Comments

blogjunkie’s picture

I've not installed Drupal on Hostgator before, but I would double check that you've uploaded the .htaccess file that came along with your Drupal install. These files are frequently hidden on most PCs or Macs because of the '.' name. Also make sure that its writable by the server.

Also, it would be helpful if you go into Admin -> Settings -> Clean URLs and tell us what you got from the Clean URL test. Good luck!

amariotti’s picture

I would definitely look for the .htaccess file before doing anything more. That is the file that most of the documentation refers to. Do that and report back. There are details on the docs referring to exactly what needs to be done to them.

thecalebrogers’s picture

Since I have root access to my server, I would prefer to do the rewrite rules directly to the conf files, but it's not the biggest deal. As far as the .htaccess file is concerned, it doesn't seem to help. I can't enable clean urls, and when I run the test, I get a page not found error. Mod Rewrite is loaded in apache, so I'm not really sure what's going on.

For the .htaccess file specifically, I have the code from this page: http://cvs.drupal.org/viewvc.py/drupal/drupal/.htaccess?view=markup . I've tried it with with RewriteBase / commented out and not commented out, both with the same results. With all that's going on, I am led to think that there's something up with my server's config. Since there are so many files, maybe I just haven't found and edited the right one yet. But, that's just the theory I'm going on right now. I'm always open to other options.

Thanks,
Caleb
http://www.education-finder.net

amariotti’s picture

Wish I could be of more help. Unfortunately I don't have much experience when it comes to servers. I would imagine that there might be some settings somewhere that might be overwriting your conf files. Let us know what you do to fix it for future reference. :)

drupalnewbiehaha’s picture

I had the same problem when I first installed drupal, here is my quick hack.

Go to .htaccess Within

# Put where mount your drupal
# For instance, if your drupal is at http://yoursite/drupal
# then
# RewriteBase /drupal
RewriteBase / # <-- add this line
RewriteCond %{REQUEST_FILENAME} !-f
....

Hope this helps

thecalebrogers’s picture

I actually didn't have to change anything to get it to work. Well, that's not entirely accurate. Here's the whole story.

I contact my host's support department so they can double-check my server to see if mod rewrite was on and functioning properly. It was. In the mean time, I started looking to the .htaccess file. Upon opening up the copy on the server, I saw that it was blank. I don't think a blank .htaccess file will help out much. So, I went to the drupal docs and did a fancy copy and paste from the drupal 6 .htaccess (even though I was running version 5.5 at the time, I only saw the current v6 file in the drupal docs (I don't have the url in front of me and I don't feel like searching for it right now). So, what I did was open up my Mac terminal, navigated to my drupal install folder, renamed .htaccess to htaccess.txt and then uploaded that file to my server. Once it was up there, renamed it and clean urls worked.

It was like magic. So, the moral of the story is that you should rename your .htaccess file (hidden by default in Mac OS), then upload it and rename it and everything *may* be fine for you. It was for me.

The End.

Thanks,
Caleb
http://www.education-finder.net

danfinney’s picture

I am having the same issue with the Clean URLs on hostgator. I tried pasting in the .htaccess file from a Drupal site I have running on GoDaddy, but that did not work.

1. Can you link me to the .htaccess file you found that did work? (I was not able to pull it up by searching)

2. Please confirm the location of the .htaccess file. When you login via FTP your Drupal install is inside of the directory public_html. This is where I have been putting the .htaccess file. Are you putting it somewhere else?

Drupal Indianapolis Web Design

arlenvargas’s picture

chaoscube,

Thanks so much!!!!

bostonlatin’s picture

@chaoscube Thanks!

ablewave’s picture

Hi guys,

Thanks for the head start, following this thread I got my clean URL's working on my temp URL at Hostgator. A list of the htaccess files for each drupal version can be found here:

http://cvs.drupal.org/viewvc.py/drupal/drupal/.htaccess?view=log

The link to the one posted by chaoscube was for 7.x When I navigated from there to the one for my version (6.6), I created a new file (htaccess-hostgator.txt), pasted, changed the rewritebase (/~accountusername no trailing slash appears to work) and uploaded to web root (public_html). Then you can change the filename on the server. I did not have luck just pasting the content into the already existing htaccess file.

Do it this way and it should come right up for you. Thanks to those who started me in the right direction!

tsaw’s picture

I am using Host Gator and love their product and service / support. The above suggestion fixed clean urls on my setup.

I have had this issue before - it's only when I am setting up under the test path for the site - until the DNS nameservers update and switch over. When developing a site - that is usually how I do it - develop under the temp path and when the client says go live then I update the nameservers to make the site go live.

Anyhow - in the .htaccess file around line number 105 you will see something like this:

# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
# RewriteBase /

Just change that by un-commenting the line:
# RewriteBase /

Change it to:
RewriteBase /~your-host-gator-account-username

Just replace your-host-gator-account-username with the account username that you were given for your hosting account.

Just put it back to the way it was when the DNS updates and the site goes live on the real domain name.

Host Gator isn't the issue - it's just the info that is in .htaccess file - update that and you will be good to go.

Hope this helps someone!

mr1’s picture

Thanks! This worked for me.. I completely overlooked adding the ~account..

jeffdufour’s picture

I had the same issue on a new Drupal 7 install on a dedicated server at inmotionhosting.com. I followed your instructions and it solved the problem. Thanks So Much for posting!

Anonymous’s picture

I was going crazy trying to figure it out what I had wrong. I couldn't get the clean urls to work, I did put the directory on the RewriteBase with the tilde and finally get them work.

Strange thing, is that I have two virtual hosts on the same VPS, in one I have Drupal 7 installed and in the other Drupal 6. I could make the clean urls work on the Drupal 6 installation but on the Drupal 7.

Any ideas what it might be?

Thanks in advance.

thecalebrogers’s picture

Here's what I figured out: For some reason the 6.0 .htaccess file wasn't working. I double-checked with hostgator support and they confirmed that the server was configured properly for mod rewrites.

My initial Drupal 5.5 and 5.6 .htaccess files were blank on the server. It was quite weird. I uploaded everything, opened the file in Dreamweaver, and it was blank. Then I sshed into the server, located the file in question, and opened it from the command line. It was blank. My local system is a Mac running os 10.4. By default, hidden files stay hidden, and you have to do some hoop jumping to unhide them. Well, somewhere along the way, duing the uploading, the file went blank. This only happens when uploading the file from a mac.

To get around this issue, I just located the hidden .htaccess file on my machine and renamed it htaccess.txt. Then I uploaded it, renamed it, and everything worked just fine. Here is the full text of the .htaccess file:

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
  Order allow,deny
</FilesMatch>

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On
  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600
  # Do not cache dynamically generated pages.
  ExpiresByType text/html A1
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # If your site can be accessed both with and without the 'www.' prefix, you
  # can use one of the following settings to redirect users to your preferred
  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  #
  # To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/... will be redirected to http://www.example.com/...)
  # adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
  # RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
  #
  # To redirect all users to access the site WITHOUT the 'www.' prefix,
  # (http://www.example.com/... will be redirected to http://example.com/...)
  # adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

  # Modify the RewriteBase if you are using Drupal in a subdirectory and
  # the rewrite rules are not working properly.
  #RewriteBase /drupal

  # Rewrite old-style URLs of the form 'node.php?id=x'.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^id=([^&]+)$
  #RewriteRule node.php index.php?q=node/view/%1 [L]

  # Rewrite old-style URLs of the form 'module.php?mod=x'.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
  #RewriteRule module.php index.php?q=%1 [L]

  # Rewrite current-style URLs of the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

# $Id: .htaccess,v 1.81.2.3 2007/09/21 12:24:22 drumm Exp $

I hope this information helps. I was getting pretty frustrated.

Thanks,
Caleb
http://www.education-finder.net

danfinney’s picture

Caleb,

Thanks for your help! (Mac user here too btw) I tried replacing the .htaccess file with the code you supplied, but it did not work. I have decided to cancel my HostGator account after receiving the following helpful email from the HostGator Technical support team:

Dan,

You would need to get drupal to assist you with this 3rdparty application.

Thanks,
Thank you,

Josh (Omitting his last name)
Systems Administrator & Level I Support
HostGator LLC.
http://support.hostgator.com

As a Mac user, I have come to expect better support from vendors. Here is a helpful link for anyone who may come to the same conclusion. HostGator Cancel form

Drupal Indianapolis Web Design

xevious’s picture

( /public_html/.htaccess contents)

----- Begin file contents ----------
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
------- End file contents ------------

-Douglas

brei9000’s picture

I also have Host Gator and this solution work for me. Drupal 6.8.

ttnk’s picture

Domain has changed and is now pointing to hostgator and everything is working just fine, i really dont know how the no-domain was affecting, but is working right now. Ignore my comments under these please.

I have this code at the end of my .htaccess on hostgators installation

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /site
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ /site/index.php?q=$1 [L,QSA]
</IfModule>

I'm running drupal on a subdirectory called site (/public_html/site/.htaccess)
i realy dont know whats wrong, maybe i am not seeing the obvious, could some body help me please? i have spent 2 days trying to make clean_urls work, i have talked 3 times on livechat and they told me that module rewrite is enabled and working, that "AllowOverride" is set to "All" on the httpd.conf, Im using Drupal 6.13. btw.
The domain isn't pointing to the hosting on hostgator yet, could that be the reason why this isn't working? I don't thinks so because i have the exact site running on localhost without any domain with working clean_urls. I also have 2 drupal sites on godaddy and 1 on verio with clean_urls too.

I really appreciate if somebody could tell me what am i doing wrong.

splashworx’s picture

Hi, ttnk.

I'm having the same issue where I'm unable to point the client's domain to the server/host until the production site is completed (this must be a common thing, surely?). The host support staff say this is the reason why Clean URLs aren't working (although they're unable to tell me what needs to be done). Interesting that you have other sites without domains that work ok...

I've modified settings.php and .htaccess without luck.

My other question (as it may be yours as well) is what will happen to the database if we get Clean URLs working on the yet-to-be-delegated server/host URL, ie. once the domain is pointed to the DNS, will we need to then modify URLs within the database and modified settings.php & .htaccess files?

- Tim

ttnk’s picture

Dont worry about that because at the time you get the clean_urls working the internal paths change automatically. At least that happened with my site.
From what i have read about, it uses both paths, the clean and unclean ones, both work when you activate clean_urls.

My suggestion is that you keep on looking for this particular issue because im not very experimented in drupal yet, i have been using it for about 1 month and a half.

Good luck.

vectorfrog’s picture

I've been working on this for 2 days, have been on live chat twice and still no dice. Yesterday I had the DNS servers pointed to hostgator, hopefully that will solve the problem, though it seems so weird since I had clean URL's working on my local machine just fine.

This is my first drupal project, and this is by far and away the most frustrating part of it.

vectorfrog’s picture

Just wanted to let everyone know that my experience with hostgator was the same. Couldn't get clean URL's to work, but as soon as the DNS came through, it's up and running like a champ!

markosaurus’s picture

I've had this issue before, and I've just realized what it is again!

I'm doing the same as a lot of people on here and developing on a temporary domain until my domain starts to resolve to my hosting account after changing the DNS settings.

For some reason (possibly security), I have never found a way to get drupal clean urls running on a domain which is based at a temp address, I'm going to try and sus it out though. Will report back if I manage to fix it.

chuckdrew’s picture

I am not totally sure on the implications of this, an apache guru could probally say more, but replacing the .htaccess file code with this solved all my problems with clean URLs on Host Gator:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?q=$1 [L]

Hope this helps!

Chuck

aza101’s picture

Following chucks last post works fine, please do let us know if there is anything wrong with it but it works perfectly for me

Getting clean URLs to work on a Host gator reseller package using drupal 7, locate the file called .htaccess which is in the public_html file. This is the file where your drupal would have been installed to.

Open the .htaccess file by highlighting it and clicking edit in the menu at the top, then delete what is in that file and replace with:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?q=$1 [L]

Now check the box for clean urls and it will work :)