htaccess and Clean URLs

Aran Deltac - January 21, 2005 - 15:36

Allright, I am so confused. INSTALL.txt says:

"If you want support for clean URLs, you'll need mod_rewrite and the ability to use local .htaccess files. (More information can be found in the Drupal handbook on drupal.org.)"

So, I go looking at the handbook in the only spot that I can find any information about Clean URLs, Handbook->Administrator's Guide->Configuration->Initial Configuration->Clean URLs, and this is what it says:

"... By enabling clean URLs, you will be able to get rid of the "?q=" in the URL and make it "clean." Note that this works only for Apache servers which have mod_rewrite installed. Talk to your web host or consult the Apache documentation for more information."

All I'm looking for is a sample mod_rewrite ruleset that support clean URLs. Everywhere I look it says to look somewhere else. 'Bout to pull my hair out here.
Thanks.

Aran

already present in .htaccess

barneson - January 21, 2005 - 15:43

The rules that allow clean urls are already present in the .htaccess file distributed with Drupal. Assuming that you are running on an Apache host with mod_rewrite installed (probably likely) all that is needed to enable clean urls is to change the setting on your admin page: http://example.com/?q=admin/settings.

You may need to edit the .htaccess file if running Drupal in a subdirectory. See the comments in .htaccess for details.

--
Bjorn
http://choirgeek.com
because there's no 'I' in ensemble

clean url option disabled

sulleleven - January 24, 2005 - 18:46

i just added mod-rewrite to apache config and restarted apache... it loaded ok.
in drupal (cvs), i go to admin/settings and the option to enable clean urls is disabled (cant select option). I edited htaccess to allow for modrewrite... I am in a subdir on this particular installation, and edited htaccess accordingly.

why is the setting disabled for me?

thanks

Avoid breaking

Steven - January 24, 2005 - 19:04

If the setting is disabled, it means there is something wrong with the Clean URL set up, and enabling the option would cause your site to break. You'd need to do db changes to get back in.

--
If you have a problem, please search before posting a question.

ah, a safety measure added

sulleleven - January 24, 2005 - 19:07

ah, a safety measure added in cvs.. I been through that detour before....

so, though i setup drupal before I setup the apache mod rewrite.... how do I get drupal to understand its ok now? The module is loaded.

maybe there is a relation...

sulleleven - January 24, 2005 - 19:08

maybe there is a relation... because I also get this error printed whenever I go into settings.
warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: host/servname not known in path/includes/common.inc on line 230.

warning: fsockopen(): unable to connect to projects.ultrastar.com:80 in path/includes/common.inc on line 230.

i think its firewall related....

..site to break

Dream_Theater - February 11, 2005 - 18:45

I had that problem....the setting was disabled, so I put it to enabled. Fuck!, mi site is break. It was a true problem.

Still Doesn't Work

Aran Deltac - January 27, 2005 - 19:19

OK, I found the .htaccess. It still doesn't work tho. For some reason brining up / brought back a page not found and accessing any pages brought the pages back as if all stylesheets and images were broken. Looks like mod_rewrite is rewriting for all files and ignoring the !-f and !-d rewrite conditions. Anyone have this problem? Temporarly I set my rules to:

RewriteCond /path/to/my/doc/root%{REQUEST_URI} !-f
RewriteRule ^/(.*)$ /index.php?q=$1 [L,QSA]

It seems like the {REQUEST_FILE} env var that is used in the default drupal .htaccess is not being created in my Apache. Here's the options that I configured my 1.3.33 Apache with:

--activate-module=src/modules/php4/libphp4.a \
--disable-module=negotiation --disable-module=actions --disable-module=autoindex \
--disable-module=userdir --disable-module=imap --disable-module=asis \
--enable-module=rewrite

I modified .htaccess and httpd.conf

DKL64 - February 2, 2005 - 17:43

Here's how I got clean URLs to work :

First, modify .htaccess. Uncomment RewriteBase and to point to my subdirectory :

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

Second, uncomment rewrite_module in Apache2 httpd.conf

# Feb 2005 - uncomment rewrite_module to allow Drupal clean URLs
LoadModule rewrite_module modules/mod_rewrite.so

Restart Apache to reread httpd.conf, and now things are OK.

David

http://luhman.org

Don't forget AllowOverride All!

JoshuaE1974 - February 6, 2005 - 20:30

I was having this problem also, but by adding:

AllowOverride All [in httpd.conf, search for .htaccess]

I got it working.

A better example.

icybyte - February 7, 2005 - 10:54

This confused the living daylights out of me, eventually someone told it to me straight, which is how it should be - edit your httpd.conf/apache.conf file and in your vhost section, add the following directive:

<Directory /var/www/htdocs/hosts/somesite.com>
     AllowOverride All
</Directory>

that's all there is to it.

That works

m.sosin@james-h... - February 19, 2008 - 09:23

After two days of searching, finally it works.

Thanks for that post icybyte

Michael

htaccess file comments

matt@www.roampr... - July 27, 2005 - 08:45

I'm installing/modifying a new Drupal site via Mac OS X. The system hides .htaccess files, so I can't see it on the dl'ed Drupal tarball.

Can someone post a copy of the code the htaccess file contains. I then will find it easy to paste this code into a txt file marked 'htaccess', upload to my root dir, then add the '.' to make it '.htaccess' on the server.

Many thanks

Matt

>> http://visint.tv: V.I.A.
>> http://roamproject.com: mobile video/art

htaccess code for drupal 4.6.2

matt@www.roampr... - July 27, 2005 - 09:36

Ok, I found the answer by using Mac OS X utility, Tinkertool: http://www.bresink.de/osx/TinkerTool.html

But I'll post the code here for information purposes, so others won't have to enable hidden files, etc:

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<Files ~ "(\.(inc|module|pl|sh|sql|theme|engine|xtmpl)|Entries|Repositories|Root|scripts|updates)$">
  Order deny,allow
  Deny from all
</Files>

# 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 exist in sites/default/settings.php, but
# the following cannot be changed at runtime. The first IfModule is
# for Apache 1.3, the second for Apache 2.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
</IfModule>

<IfModule sapi_apache2.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

  # 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.66 2005/03/20 19:15:00 dries Exp $

>> http://visint.tv: V.I.A.
>> http://roamproject.com: mobile video/art

htaccess not recommended

OldHeadNewWall - July 27, 2005 - 20:24

Apache advises here that you avoid enabling .htaccess unless you must.

My alternative was to create a drupal.conf file and put it in my conf.d directory (the typical place where you put extra configuration files to avoid polluting httpd.conf so that upgrades work, etc.) My drupal.conf file has this in it:

<Directory "/www/drupal">

Include /www/drupal/.htaccess

</Directory>

This avoids the issues Apache mentions. And now I can upgrade both Apache and Drupal with no downside.

I'm not sure what I've done

Danland - January 22, 2006 - 23:49

I'm not sure what I've done here, but it's managed to get the SEF urls workings.

Basically I stripped the htaccess file down to five lines

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

The error 500 server error stopped and SEF urls are working. The original htacces was:

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<Files ~ "(\.(inc|module|pl|sh|sql|theme|engine|xtmpl)|Entries|Repositories|Root|scripts|updates)$">
  Order deny,allow
  Deny from all
</Files>

# 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 exist in sites/default/settings.php, but
# the following cannot be changed at runtime. The first IfModule is
# for Apache 1.3, the second for Apache 2.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
</IfModule>

<IfModule sapi_apache2.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

  # 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.66 2005-03-20 19:15:00 dries Exp $

I've know idea what all those lines do, but I appear to be able to get the web site working with clean URLs wihtout it. I hope this helps someone because I've been banging my head against a wall with it all day.

Backslash

Kaelon - April 14, 2006 - 02:06

I found that this problem was fixed if I added a backslash before index.php?q=$1 right before the close tag.

ModRewrite is enabled by

vidmarc - June 8, 2006 - 13:06

ModRewrite is enabled by default on the server I'm using. However, I'm unsure as to how to get it working with Drupal's .htaccess file. Here's a link to my service provider's info page

Modifying Apache Webserver configuration?

When I place the unmodified Drupal .htaccess file into my root folder, the administer -> settings -> general settings -> 'Run the clean URL test' does not work, and I get an 'Error 404: File not found' message. So... how do I get this working? What do I need to change in the .htaccess file? I've bee fiddling about with this for a few hours now, and I'm not getting anywhere.

[edit]

Fixed! I used the above code and it now works fine:

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

-----------------------------------------------------------------------
Mondo Erotico
DVD News + the cult films of Borowczyk, Franco, Metzger + Rollin

same problem with 1and1. Thanks for this solution!

Axel_V - August 16, 2006 - 16:35

Thanks a lot vidmarc. You've made my day. I was struggeling with this for a few hours now and all I got from 1and1 was this undecipherable comment:

In Drupal's .htaccess file you might find a statement just above the
Rewrite rules. Now, some web hosters, especially 1&1 Internet, seems to
"hide" the module although it is there.

So to make Clean URLs work in such an environment, simply delete the
line or place a # in front of it to comment it out, look all the way
down and find and delete that to (or palce an # in front of it). ...

They are just useless but thanks for your solution.

iPowerweb does the same thing

Nephus - September 20, 2006 - 17:24

Just a heads up to anyone else using iPowerweb hosting, the same trick of commenting out the <IfModule mod_rewrite.c> line makes clean urls work perfectly.

edit: actually, that's the fix suggested by your host, not the one you did. Works like a charm though. Just comment out that one line, and *poof* it works.

1and1

gratefuldad - January 27, 2007 - 23:38

I also use 1and1, running Drupal in a subdirectory. I just uncommented the RewriteBase line in .htaccess and Clean URLs seems to be working now.

Thank you!

meerkat - July 13, 2007 - 00:12

This worked for me on 1&1 when all other recommendations failed.

Thanks to Kaelon for his post.

james_klicker - July 11, 2007 - 23:15

Undoubtedly saved me additional hours of frustration.

Any idea why this works?

for me, this does not work

headkit - October 10, 2007 - 14:42

for me, this does not work on 1und1 (germany).
i am very unhappy about that...

I have two drupal-sites running, being placed into the folder CMS of the basedirectory "www.basedir.de/CMS".
the additional site could be reached by "subdir.basedir.de"

I tried

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

and every single possibility where to put another "/" - nothing helped.

got it. this

headkit - October 11, 2007 - 11:45

got it.

this helps:

#RewriteBase /CMS
RewriteRule ^(.*)$ /CMS/index.php?q=$1 [L,QSA]

lets now try the second site with "subdir.basedir.de"...
wish me good luck!

That's what did it for me.

dpakatheman - April 28, 2009 - 23:50

That's what did it for me. I'm using 1&1 and had drupal in a subdir. So I was trying to access:
http://www.example.com/Drupal-5.16/admin/settings/clean-urls

But in only worked when I modified the standard* .htaccess with:
RewriteRule ^(.*)$ /Drupal-5.16/index.php?q=$1 [L,QSA]

*(note: I also needed the "AddType x-mapp-php5 .php" fix to install drupal)

Thanks headkit!

i was using 1 and 1 and this is the code that worked for me

kool_zool - November 8, 2007 - 13:50

i was using 1 and 1 and this is the code that worked for me:

#
# 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
</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>

# 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 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} ^example\.com$ [NC]
  # RewriteRule .* http://www.example.com/ [L,R=301]
  #
  # If you want the site to be accessed only WITHOUT the www. prefix, adapt
  # and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^www\.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.
  RewriteBase /

  # 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.82 2007/01/09 09:27:10 dries Exp $

find me at buzz digital

it works clean urls, 1and1, .htaccess

kool_zool - November 8, 2007 - 13:56

i got it working on 1and 1 with a bit of different code. so hopfully some1 can look at this and find it useful

#
# 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
</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>

# 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 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} ^example\.com$ [NC]
  # RewriteRule .* http://www.example.com/ [L,R=301]
  #
  # If you want the site to be accessed only WITHOUT the www. prefix, adapt
  # and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^www\.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.
  RewriteBase /

  # 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.82 2007/01/09 09:27:10 dries Exp $

find me at http://www.buzzdigital.co.uk/

1and1 Still Doesn't Work

zathrasjr - November 13, 2007 - 23:09

I've gone through every version of a solution for 1and1 hosting accounts and nothing has worked. I've even tried placing the .htaccess file in the root of my hosted space without any luck. I even tried coping and pasting some of the above .htaccess solutions without success.

I'm wondering if the fact that I'm using a subdomain could be causing me problems. So my domain name goes like this:

subdomain.domain.com

The subdomain URL is being directed to a subdirectory in my hosted space at 1and1. When trying the above solutions I started getting 404 errors, but before I made any changes I was getting 500 errors.

Anyone have any ideas?

Don

No Luck with 1 and 1

danlikesbikes - November 22, 2007 - 01:53

I've been using 1 and 1 for a long time now and have tried on numerous occasions for extended periods of time to get clean urls working on my site with absolutely zero luck. My configuration is just in the base folder "/." so my code looks like this

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.
  RewriteBase /

  # 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]

I've also tried
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
and
RewriteRule ^/(.*)$ /index.php?q=$1 [L,QSA]
and
RewriteRule ^/(.*)$ index.php?q=$1 [L,QSA]
and
every other possible combination listed here...
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteRule

I am exhausted.

1and1 Fix

joffwilliams - December 19, 2007 - 13:06

Hi,

I'm setting up a Drupal site for a client on their 1and1 account and had exactly the same problem.
After spending half an hour on the phone to their tech support I found a solution that worked for me.

Simply change the following line:

RewriteEngine on

to:

RewriteEngine ON

Changing the word 'ON' to uppercase seemed to do the trick. I've no idea why, but clean URL's are now working!

Hope this helps,
Joff

1and1 clean url fix

yosemite - January 8, 2008 - 22:24

1and1 clean url fix

i added this
RewriteBase / (add path to drupal directory if not in base)

after

RewriteEngine on

made it work

Thx!

Tim-R - February 5, 2008 - 09:31

This solution works fine for my subdomain! It is appropriate for hosting in Poland at nazwa.pl.

it not working at nazwa.pl

adpo - August 1, 2008 - 11:03

it not working at nazwa.pl

I am having the same

jsloyer - January 17, 2008 - 18:06

I am having the same problem, for some reason mod_rewrite is not handling the URL's correctly.

The following is the HTML for importing the style sheets:

<link rel="stylesheet" href="sites/all/themes/themname/assets/css/content-vertical.css" type="text/css" media="screen" />
<link rel="stylesheet" href="sites/all/themes/themname/assets/css/sub-content.css" type="text/css" media="screen" />
<link rel="stylesheet" href="sites/all/themes/themname/assets/css/print.css" type="text/css" media="print" />
<link rel="stylesheet" href="sites/all/themes/themname/style.css" type="text/css" media="screen" />

I have the web developer plugin enabled and it looks like it is appending the current part of the site to where the CSS files are at, for example:
http://www.domain.com/admin/settings/sites/all/themes/themename/style.css.

Anyone have any ideas?

Anyone have a .htaccess file

JonGirard - January 29, 2008 - 21:44

Anyone have a .htaccess file fix to enable clean urls on bluehost..?

I still have had no luck..

Any help is appreciated,
Jon Girard

have you got the answer yet?

Tony_Rayman - June 13, 2008 - 19:08

Jon,
Did you ever get this to work?
I am on Bluehost and have just started my search. If you already found the answer and are willing to share it I would really appreciate it.

If you have not found the answer yet and I find it I will contact you with it.

Hi There, Thanks for the

JonGirard - June 24, 2008 - 04:36

Hi There,

Thanks for the reply to my comment, no one really seems to care about blue-host people :'(

I must of spent countless hours going through practically every post there was out there, never did get any of them to work.

Finally I was so exhausted, and had gone past the launch date of my client's websites trying to solve the problem, I just gave up. If an answer to this is ever found, I'll finally be able to get courtenaystory.com & bostondanceco.com running on clean URLS!!

Anyhow, a little while ago a user "erjiang fu" contacted me by email, he was also looking for a fix to bluehost clean URLS. I believe he is also still looking.

Keep our fingers crossed, and please do let me know if you ever find an answer.

Jon.

Do I need this code in .htaccess file?

Thomasr976 - April 13, 2008 - 15:41

I have a drupal 5.7 install. my .htaccess file is exactly like the file that came with drupal 5.7. I have enabled clean urls, global redirerect, path auto. For some reason I have the following code appended to the bottom of standard .htaccess file. My Cpanel is reporting a log error:

Sat Apr 12 23:34:21 2008] [notice] mod_fcgid: call /home/millenni/public_html/index.php with wrapper /usr/local/cpanel/cgi-sys/php5

Here is the code that appears right at the bottom of the .htaccess file.

  # 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.4 2008/01/22 09:01:39 drumm Exp $

Note the following code is extra

RewriteCond %{HTTP_REFERER} !^http://millennialliving.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://millennialliving.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.millennialliving.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.millennialliving.com$      [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]

My host thinks I really don't need this exta code and suggests using the standard .htaccess code sans the extra code below. I have no idea how the code got there. Please help.

Thanks for looking over

hey i got it ty

jwxie518 - June 13, 2008 - 23:06

hey i got it
ty

My clean urls problem has been solved

fujiang - July 6, 2008 - 12:07

I am Erjiang Fu the one Aran mentioned and had the same problem of enabling clean urls for Bluehost web hosting.

I have just solved my problem today.

In fact, I meant that I have just identified where the problem resulted from.

For me, it was the matter of the understanding of drupal root directory.

I installed my drupal in a subdir, e.g. /public_html/abc

My problems were (maybe problems of Bluehost hosting service):

1. The .htaccess should in the drupal root folder '/public_html/abc' not '/public_html'

2. Then the RewriteBase subdir should be '/' not '/abc' as I thought

My solution:

So my .htaccess file in 'abc' folder has the lines below:
____________________
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
____________________

Conclusion:

1. .htaccess should be in drupal root folder (where you installed your drupal, not the /public_html.
2. the RewriteBase should be '/' because the .htaccess is already in the drupal root folder.

Am I clear here?

Hi Aran, Let me know if you still can not work this out.

Problem with 1and1 clean urls for subfolder

yourownfriend - January 18, 2009 - 14:54

Hi everyone:

I'm still having problems with -clean urls- with 1and1 for a subfolder

the code that I'm trying is

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

I've tried it with this variations too:

1) RewriteEngine on

2) RewriteBase /subfolder

3) RewriteRule ^(.*)$ /subfolder/index.php?q=$1 [L,QSA]

____________________________________

I've also tried putting the .htaccess file directly on the subfolder but didn't work either.

Any suggestions?

Thank you!

HD

1and1 clean urls

yosemite - January 19, 2009 - 00:32
 
 

Drupal is a registered trademark of Dries Buytaert.