Welcome to the Geeks & God Static Archive. Read more »

Drupal's Clean URLs

G&G Moderator
G&G Podcast Host
NonProfit's picture
Joined: 06/06/2007

Hey, I've set up a few sites by now and never had this problem before (but I'm using a new host this time.)

My 6.3 install failed the Clean URL test. I called tech support and they said to include "RewriteEngine on" in my .htaccess file. (The Drupal install includes this out of the box, no?) The Handbook Page on Clean URL's speaks of adding "AllowOverride All" to httpd.conf "so that local .htaccess commands will be run for your site" which I believe is an Apache config file that I don't have access to.

Any thoghts?

-NP

G&G Podcast Host
Matt Farina's picture
Joined: 06/01/2006
Is your .htaccess file there?

The first thing to check is that your .htaccess file was uploaded to the server. That has bitten me a few times.

Matt Farina
Geeks and God Co-Host
www.innovatingtomorrow.net
www.mattfarina.com

Matt Farina
Geeks and God Former Co-Host
www.mattfarina.com

Joined: 05/03/2007
Also ensure mod_rewrite is loaded

If your .htaccess is uploaded and correct, check phpinfo() and ensure the mod_rewrite module is loaded. You should see it in the list of loaded modules in the apache2handler section. You cannot enable RewriteEngine without it. I believe it is loaded by default.

Since they told you to enable RewriteEngine in your .htaccess, the AllowOverride directive is probably already enabled, which defines whether the default settings can be overridden by users' .htaccess files.

G&G Moderator
Darrin's picture
Joined: 01/29/2007
That has happened to me a

That has happened to me a few times also. Im searching all around trying to fix it then I feel like a total tard when I realize I didnt upload the .htaccess file.

G&G Moderator
G&G Podcast Host
micah's picture
Joined: 06/21/2007
cancel

Edit: never mind. redundant comment.

G&G Moderator
G&G Podcast Host
NonProfit's picture
Joined: 06/06/2007
My clean URL woes continue

Hey Matt, techmate, CheckeredFlag and Micah,

I'm still banging my head against the wall...how do I load the mod_rewrite module in php.info?

.htacccess is loaded in the root folder and the Path module is enabled and RewriteEngine is on:

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

# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php

# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
  ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>

# 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
  php_value memory_limit 32M
</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
  php_value memory_limit 32M
</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
  php_value memory_limit 32M
</IfModule>

AddType x-mapp-php5 .php


# 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/...)
  # uncomment and adapt 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 or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line:
  # RewriteBase /drupal
  #
  # If your site is running in a VirtualDocumentRoot at http://example.com/,
  # uncomment the following line:
  # RewriteBase /

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

# $Id: .htaccess,v 1.90.2.1 2008/07/08 09:33:14 goba Exp $

php.info is located in modules/php

; $Id: php.info,v 1.2 2007/06/08 05:50:55 dries Exp $
name = PHP filter
description = Allows embedded PHP code/snippets to be evaluated.
package = Core - optional
version = VERSION
core = 6.x

; Information added by drupal.org packaging script on 2008-07-09
version = "6.3"
project = "drupal"
datestamp = "1215640509"

Also, I understand changes to .htaccess won't take effect until the server is reset. Is the possible to do this sans telephoning the host each time?

Thanks!

-NP

EDIT: I created a phpinfo file. I'm not quite sure what I'm looking at, but I don't see mod_rewite installed.

G&G Moderator
G&G Podcast Host
NonProfit's picture
Joined: 06/06/2007
Clean URLs: Solved

OK, it took six hours but a solution was reached.

Adding a slash in the .htaccess RewriteRule
from:

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

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

Thanks for your help.

Blessings! -NP

G&G Moderator
G&G Podcast Host
NonProfit's picture
Joined: 06/06/2007
Error 500 - Internal server error

OK, once I got Clean URLs working the site started throwing Error 500 - Internal server errors. By adding AddType x-mapp-php5 .php to the .htaccess, it seems to be OK now. (I'm beginning to wonder about 1and1.com's hosting... Blessings! -NP

S
S's picture
Thanks

Wow, your 6 hours saved me at least that much! I already had the AddType x-mapp-php5 .php part, just needed the "/"!

Thank you!

J.J.
S's picture
Thanks NonProfit Adding a

Thanks NonProfit

Adding a slash in the .htaccess RewriteRule worked for me.

-

Hi, I got the same problem wif NonProfit. I just installed a website (drupal, server linux) into new hosting. Then to make sure the path, I have to let the clean urls enabled right? After that, I noticed that my both radio button is return to grey. Anyway my website is working properly but with the url like example: "http://www.mywebsite.my/index.php?q=club_facilities". How to solve the problem? I probably checked all the .htaccess file is over there in the server together wif index.php file and so on. Please check my .htaccess file below:

Somebody may help me what is the cause of this problem???? Really appreciated it guys.

Thanks

===========================

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.

Order allow,deny

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

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php

# Force simple error message for requests for non-existent favicon.ico.

# There is no end quote below, for compatibility with Apache 1.3.
ErrorDocument 404 "The requested file favicon.ico was not found.

# 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_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0

# PHP 4, Apache 2.

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

# PHP 5, Apache 1 and 2.

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

# Requires mod_expires to be enabled.

# 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

# Various rewrite rules.

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/...)
# uncomment and adapt 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 or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
#RewriteBase /

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

# $Id: .htaccess,v 1.90.2.3 2008/12/10 20:04:08 goba Exp $

================================

Joined: 03/28/2012
I've just installed a drupal

I've just installed a drupal website on my ftpperso and It's impossible for me to set up the url rewriting that is very inconvenient because I need to use some modules like pathauto.

I'm using the hosting of free.fr and you can check my site at mysite

Did someone already face the same problem? I've found some solutions on the website but only for D5.x

Thanks