Problem with enabling clean url in drupal.  

I was trying to enable clean url on my new build muscles faster site and ran into the following problem.

The requested URL /admin/settings/clean-urls was not found on this server.


I tried to enable permissions in the settings and also some other hacks but nothing worked. I had another drupal installation on same server with clean urls working so this file not found error was definitely not related to my server. After searching over internet, i finally surmised that the problem is definitely related to the .htaccess file. However I was not able to correct the .htaccess file settings myself. Finally after a lot of searching and struggling I got hold of .htaccess file that may solve this problem from one of the drupal nodes.

I am posting the contents of .htaccess file below. All you need to do is to open a notepad, paste the content of this file below and save it as .htaccess file and upload it.

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.

Order deny,allow
Deny from all


# 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

php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0


# PHP 4, Apache 2

php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0


# PHP 5, Apache 1 and 2

php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0


# Reduce the time dynamically generated pages are cache-able.

ExpiresByType text/html A1


# Various rewrite rules.

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 rules for static page caching provided by the Boost module
# BOOST START

AddCharset utf-8 .html

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]


# $Id: boosted.txt,v 1.4 2006/12/05 10:39:19 arto Exp $

It worked for me:)

Thanks

PS:If this post helps you, please leave a comment and support.

AddThis Social Bookmark Button

9 comments

  • Zen Albatross  
    July 18, 2007 at 1:24 AM

    I have the same exact problem you had, trying to enable clean url's in drupal. I tried what you suggested, but the second I created that .htaccess file with the contents you posted, my apache server went nuts and gave me an internal error where my site should be. Where exactly did you put the .htaccess? In the drupal site directory?

  • propan0  
    October 23, 2007 at 8:25 AM

    For those using XAMPP here is your solution:
    http://drupal.org/node/131734

  • Pablokenfold  
    December 6, 2007 at 11:41 AM

    I had to change the "Deny from all" line to "Allow from 127.0.0.1" (i'm testing it in a local server), and comment out the ExpiresByType line becuase it messed up my apache, but aside from that, yout .htaccess saved the day as far as clean urls go.

    Thanks!

  • Unknown  
    December 19, 2007 at 11:21 AM

    It did NOT work for me, frustrated! Page not found error. I have Apache 2.0.59, Drupal 5.5

  • Unknown  
    December 19, 2007 at 11:37 AM

    Forgot to mention, I have Windows XP Pro.

    This seems like it should be a default that is setup automatically by Apache and Drupal. Since I don't know why anyone would not use it.

  • Littoral Plain  
    January 27, 2008 at 6:17 PM

    I was getting the same error message:

    "The requested URL /admin/settings/clean-urls was not found on this server."

    ...when I tried to run the clean urls test in Drupal's admin interface.

    When I posted the .htaccess file as you have it here, though, I got the "forbidden" message when trying to access any url on my Drupal site.

    I had to change the following...

    #
    # Apache/PHP/Drupal settings:
    #

    # Protect files and directories from prying eyes.

    Order deny,allow
    Deny from all

    ... to "allow from all" and clean urls works now. "allow from all" does not allow directory listing on my site, as it is disallowed in my Apache conf file.

    Hope this is helpful...

  • Steve Brown  
    February 5, 2008 at 9:35 PM

    I just did exactly what littoral plain advised, and now it works for me as well. I did have a question as to what all of those other .htaccess lines do -- I did not have a .htaccess file before I put this whole one in, and I am wondering what else I told my server to do and what the unintended consequences might be.

  • Nick  
    February 16, 2008 at 9:16 AM

    Hi,

    I don't have a great knowledge on .htaccess file but it defines the configuration that your server is running on and also access rules for various folders and directory.

    I am sorry for those who had troubles with the solution. I will say from next time please make a backup copy of your .htaccess file.


    Steve, regarding your question, this whole issue arises if your .htaccess file gets corrupted or something. If you are using drupal there won't be any side effects.

    - Nick

  • Unknown  
    March 6, 2008 at 3:15 AM

    None of your solutions worked for me...

    Clean urls work on drupal6, on drupal 5 it makes absolutely no difference whatever I do.

    facing error 404.

    Regards

    jumi

Post a Comment