I recently found out that Clean URLs might simply not work on some web hosters, e.g. 1&1 Internet, although mod_rewrite is enabled on these systems. This is because these hosters might have some special ways of enabling mod_rewrite.
All seems set up correclty, your web hoster says that mod_rewrite is working and can be used, still Drupal complains that your web hoster does not allow the rewriting of URLs and that the system administrator should be contacted.
This is what happens:
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 (I am not an expert on large scale web hosting technology and setting up Apache Servers in typical large scale web hosting environments, so if anyone has an explanation, please let me know!)
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). Also, especially for 1&1, it's vital to tell the server where the RewriteBase is, even if it is in the web root, so change "#RewriteBase /drupal" to "RewriteBase /" if your site's right in the web root or "RewriteBase /drupal" if it is in the subdirectory "drupal"...
And this makes your .htaccess file compatible to those web hosters as the .htaccess file simply is not checking if or if not a mod_rewrite.c can be found but runs the rewrite rules anyway!
Careful though to not use this when there really is NO rewrite module on the particular web server!
Hope this helps !
Greetings, Steve
Comments
This helps that's for sure
It would have helped me just 2 weeks ago when I started my first drupal site with 1and1 !
Fortunately I found out another thread, I think it was on Drupal.org, and the solution was to edit one of the last lines of the .htaccess
instead of :
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
you add a / like this :
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
But I suppose both solutions equals the same as I have had no troubles with clean_urls ever since. Please tell me if there is a difference as I will be monitoring this thread to see your answer.
Thank you for taking the time to create this well keyworded thread.
Cheers,
Its all in defining the rewrite base
Hi,
yes, what you found basically is part of my discovery. So what's going on here...
instead of :
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
you add a / like this :
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
...is that you simply tell the rewrite engine where the rewrite base is. If you say index.php you mean an index.php anywhere in any given subdirectory, if you say /index.php you definitively mean the index.php that sits in the web root.
On my approach, this has already be done by saying "RewriteBase / " -- so it is either your approach with the RewriteBase commented out or you leave the rule as it is and add "RewriteBase / " (assuming, that Drupal is in the web root and not in a subdirectory).
Here is my complete modified Rewrite ruleset:
So you see the condition is left out as we KNOW for sure there is some sort of rewrite engine but it simply does not seam to listening on the name "mod_rewrite.c". Also, the RewriteBase is states as / (that is the web root). So you can leave the rest as it is. OR, comment out RewriteBase and add / to the index.php. Either works, but I would suggest using the "proper" way as in my example above with a defined RewriteBase of / just to keep things standardized! ;-)
Steve
Thank you for the
Thank you for the clarification, it's clear now. Cheers,
I have tried all of the above and cannot get clean urls
I have tried all of the above now I am completly locked out. I am also hosting on 1and1. my drupal files exist in the directory /compusulting. After my initial install I had an issue with my base url and could only get to my site by http:\\compusulting.net\compusulting. I changed the destination in the domains admin in the 1and1 cpanel to /compusulting and I could then reach my site now to get the clean url's up and going I have tried every variation that was mentioned above and I still get a 500 error. My last attempt at the .ht access file is below. If some with expirence with 1and1 could take a look at this it would be greatly appreciated. Thank-You website is http:\\compusulting.net
On line 56 you will notice RewriteBase /compusulting I had to do this to get my site to work at all because of my initial issue with base url, but I have tried all the variations I believe.
additional note
Hello, I am a german 1und1 customer setting up drupal 4.7.0 right now. The above mentioned modification works for me. But I lost some time on this issue anyway (maybe this pretty obvious if you are deeper in apache et. al. but I am not):
My testsite is located on an additional 3rd-level-domain like coolsite.example.com.
coolsite.example.com is linked to a folder /drupal47 within my site.
In this case the (relative) basedir to use in .htaccess falls back to /
For 6.x
If you install drupal in subdirectory, then you have to uncomment
# RewriteBase /
to
RewriteBase /subdir_name