Hello all,

I recently installed Drupal on my domain hosted by hostmonster.com using Simple Scripts.

Everything seemed to set up perfectly, except that when I try to enable the Clean URL option in Site Configuration, I am unable to do so and the following message is displayed: "Your system configuration does not currently support this feature. The handbook page on Clean URLs has additional troubleshooting information"

I opened a ticket with customer support at hostmonster, and they told me:

Dear Customer,
All you need to do it add there code to the .htaccess file.
in the cpanel click on file manager, then browser to the public_html, then right click on .htaccess and edit.

I then read the Clean URL handbook page and searched through the Drupal Knowledgebase, and I found the sample htaccess code given here: http://drupal.org/node/121834

The knowledgebase article says that some users had gotten this code to work with hostmonster drupal sites, but it didn't work for me unfortunately. Even when I put that code into my htacesss file, I still can't get the option to enable clean url's working.

(Note: I took care to follow the instructions and to modify line 68 as specified to account for the subdirectory of my drupal install.)

Are there any hostmonster drupal users out there who have successfully enabled clean urls and can tell me how? Or any good samaritans who have a hunch as to why I'm unable to do so?

Thanks a lot,

jmn

Comments

matt_harrold’s picture

If mod_rewrite is running on hostmonster.com then this might help:

http://httpd.apache.org/docs/mod/mod_rewrite.html.

Here's a cheat sheet for mod_rewrite:

http://www.ilovejackdaniels.com/mod_rewrite_cheat_sheet.pdf

jmn111’s picture

Hi Matt,

Thanks a lot for the response. I've pondered the links you sent, but unfortunately I think that writing the htaccess file myself would be way over my head!

I can sort of get the sense of what mod_rewrite is all about by reading those files, but the language is greek to me :-)

I was hoping there was another hostmonster drupal user out there who could confirm what htaccess code worked for them and could paste it in here for me...or failing that, perhaps an educated guess as to why the sample code given in the drupal knowledgebase (link posted above) wouldn't work for me and what I could change to fix it.

Anyways, thanks again for your help. Here's hoping someone out there has managed to solve this problem before.

Justin

talyia’s picture

Hi all,
After spending all day with this I FINALLY got this working!:)) I am with Hostmonster btw and have two drupal installations on my site (each in subdirectory of course). What I did after trying out several different things and reading a bazillion posts was copy the required code (which I will paste in below) into a .htaccess file and then placed a copy of it into each of my drupal installation subdirectories. You can either create a new .htaccess file on your local machine or copy the one that is already at your root on hostmonster. Please ask if you have any (BASIC) questions. I am still a newbie at ALL of this stuff since I just started w Drupal a month ago. The way I get things working (like all of you:) is by reading post after post after post:)

#
# Apache/PHP/Drupal settings:
#

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

# Set some options.
Options -Indexes
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
</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
</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
</IfModule>

# Reduce the time dynamically generated pages are cache-able.
<IfModule mod_expires.c>
  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 prefix www.
  # you can use one of the following settings to force user to use only one option:
  #
  # If you want the site to be accessed WITH the www. only, adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
  # RewriteRule .* http://www.example.com/ [L,R=301]
  #
  # If you want the site to be accessed only WITHOUT the www. , adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
  # RewriteRule .* http://example.com/ [L,R=301]


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

  # 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 rules for static page caching provided by the Boost module
  # BOOST START
  <IfModule mod_mime.c>
  AddCharset utf-8 .html
  </IfModule>
  RewriteCond %{REQUEST_URI} !^/cache
  RewriteCond %{REQUEST_URI} !^/user/login
  RewriteCond %{REQUEST_URI} !^/admin
  RewriteCond %{HTTP_COOKIE} !DRUPAL_UID
  RewriteCond %{REQUEST_METHOD} ^GET$
  RewriteCond %{QUERY_STRING} ^$
  RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0/%{REQUEST_URI} -d
  RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0/%{REQUEST_URI}/index.html -f
  RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/$1/index.html [L]
  RewriteCond %{REQUEST_URI} !^/cache
  RewriteCond %{REQUEST_URI} !^/user/login
  RewriteCond %{REQUEST_URI} !^/admin
  RewriteCond %{HTTP_COOKIE} !DRUPAL_UID
  RewriteCond %{REQUEST_METHOD} ^GET$
  RewriteCond %{QUERY_STRING} ^$
  RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0/%{REQUEST_URI}.html -f
  RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/$1.html [L]
  # BOOST END

  # 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: boosted.txt,v 1.4 2006/12/05 10:39:19 arto Exp $
Demode’s picture

Thank You Talyia!
You saved me lots of time and nerves with this one!

It seems that Apache mod rewrite is enabled by default when it comes to Hostmonster and to use it you have to have proper .htaccess file.

All I did is to copy the code you provided and voila: "enable clean url" becomes an option at Drupal admin panel!!!

Also, do not forget to rename htaccess.txt to .htaccess (at least I had to do that).

It works!!!

g.s’s picture

Works with Bluehost too!

macrodesign’s picture

Thanks a lot worked with Hostmonster; I just got 5.x installed manually coz i wanted some features that weren't available in 6.x. But got stucked with the this; thanks alot again
D

gunkle’s picture

Works with drupal 6.9 on hostmonster. Very appreciated.

curious-trick’s picture

Hi folks,

I'm setting up a Drupal 6.11 instance on Hostmonster in a subdirectory (it's in /public_html/cms/).

The code above for .htaccess doesn't work for me. I tried it with and without RewriteBase /cms and I tried it in /root (what Hostmonster calls home), in /public_html, and in /cms (my Drupal directory), and Drupal kept saying that my config is wrong for clean URLs.

Oh, and I tried most of that with and without the Path module enabled.

Any suggestions would be marvelous.

~ curious-trick

curious-trick’s picture

Clean URLs works now.

Context:
- I have not yet linked my site to a domain name, so I access it via http://[IP address]/~[my Hostmonster name]
- Path module is enabled (I don't know if this matters)
- .htaccess file is in /public_html/cms (that's my Drupal directory) and ONLY there (I tried multiple .htaccess files earlier)
- in .htaccess, I have the line RewriteBase /~[my Hostmonster name]/cms

kcn_viper’s picture

Thanks Curious Trick,
Your trick worked for me and after reading so many pages on the web as to why it was not working and after about 10 hours of effort.
Thanks a lot !!!

sandhyars’s picture

I have same problem as above.

I am transferring site from dedicated to hostmonster.
So my temporary url is like this http://74.220.215.241/~laborfa2

my code is placed under public_html/lf/main/com folder
Actually I am new in PHP.And I dont know how to write .htaccess file.I have httpd_conf of old server.

Following is my httpd_conf.I just copied it to .htaccess but it not works.

So can you tell me how to write .htaccess for that.

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
#
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any block.
#
AllowOverride All
Alias /images /lf/main/images
Alias /css /lf/main/css
Alias /js /lf/main/js
Alias /photos /lf/var/photos


DocumentRoot /lf/main/com
ServerName http://74.220.215.241/~laborfa2
ServerAlias http://74.220.215.241/~laborfa2
RewriteEngine on
#RewriteLogLevel 2
#RewriteLog logs/rewrite.log
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.php -f
RewriteRule ^/(.*)(/?)$ /$1.php [L]
RewriteRule ^/([a-zA-Z]+)([a-zA-Z0-9_]{3,15})(/?)$ /profile.php?fairid=$1$2 [L]
RewriteRule ^/([a-zA-Z]+)([a-zA-Z0-9_]{3,15})/([a-z]*)(/?)$ /$3.php?fairid=$1$2 [L]

Thanks,
Sandhya

sandhyars’s picture

I am transferring site from dedicated to hostmonster.
So my temporary url is like this http://74.220.215.241/~laborfa2

my code is placed under public_html/lf/main/com folder
Actually I am new in PHP.And I dont know how to write .htaccess file.I have httpd_conf of old server.

Following is my httpd_conf.I just copied it to .htaccess but it not works.

So can you tell me how to write .htaccess for that.

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
#
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any block.
#
AllowOverride All
Alias /images /lf/main/images
Alias /css /lf/main/css
Alias /js /lf/main/js
Alias /photos /lf/var/photos

DocumentRoot /lf/main/com
ServerName http://74.220.215.241/~laborfa2
ServerAlias http://74.220.215.241/~laborfa2
RewriteEngine on
#RewriteLogLevel 2
#RewriteLog logs/rewrite.log
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.php -f
RewriteRule ^/(.*)(/?)$ /$1.php [L]
RewriteRule ^/([a-zA-Z]+)([a-zA-Z0-9_]{3,15})(/?)$ /profile.php?fairid=$1$2 [L]
RewriteRule ^/([a-zA-Z]+)([a-zA-Z0-9_]{3,15})/([a-z]*)(/?)$ /$3.php?fairid=$1$2 [L]

Thanks,
Sandhya

dude-man’s picture

Awesome post Talyia..thank you

brizzo’s picture

This was really helpful, and worked straight away, thanks!

sandhyars’s picture

I am transferring site from dedicated to hostmonster.
So my temporary url is like this http://74.220.215.241/~laborfa2

my code is placed under public_html/lf/main/com folder
Actually I am new in PHP.And I dont know how to write .htaccess file.I have httpd_conf of old server.

Following is my httpd_conf.I just copied it to .htaccess but it not works.

So can you tell me how to write .htaccess for that.

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
#
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any block.
#
AllowOverride All
Alias /images /lf/main/images
Alias /css /lf/main/css
Alias /js /lf/main/js
Alias /photos /lf/var/photos

DocumentRoot /lf/main/com
ServerName http://74.220.215.241/~laborfa2
ServerAlias http://74.220.215.241/~laborfa2
RewriteEngine on
#RewriteLogLevel 2
#RewriteLog logs/rewrite.log
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.php -f
RewriteRule ^/(.*)(/?)$ /$1.php [L]
RewriteRule ^/([a-zA-Z]+)([a-zA-Z0-9_]{3,15})(/?)$ /profile.php?fairid=$1$2 [L]
RewriteRule ^/([a-zA-Z]+)([a-zA-Z0-9_]{3,15})/([a-z]*)(/?)$ /$3.php?fairid=$1$2 [L]

pachinsv@gmail.com’s picture

What worked for me is just to rename the "htaccess.txt" that comes with the drupal installation package to ".htaccess" and that's all! :) ... I hope this could help.

jagmeister’s picture

I had a .htaccess file which only had
"# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php"
and a .htaccess.txt file with a lot more info.
I opended the .htaccess.txt file and paste the quoted info above in the .htaccess just below the line that says
"# Apache/PHP/Drupal settings:"
then i uncommented RewriteBase /
after saving I deleted the .htaccess file and renamed the .htacess.txt to .htaccess