Clean URLs
By default, Drupal uses and generates URLs for your site's pages that look like "http://www.example.com/?q=node/83." This style of URLs can be hard to read, and can prevent some search engines from indexing all the pages of your site. Research suggests this may not be as great an issue for some of the major search engines as it once was; however, it is worth noting the recommendation from Google's webmaster guidelines stating:
If you decide to use dynamic pages (i.e., the URL contains a "?" character), be aware that not every search engine spider crawls dynamic pages as well as static pages. It helps to keep the parameters short and the number of them few.
If you are unhappy with the default URLs in Drupal, you may be able to tell Drupal to use "clean URLs", eliminating the "?q=" in your site's URLs, and this page explains how to do it. The instructions below are largely applicable only for the most common server setup, which is an Apache web server running on some flavor of Unix/Linux, with the mod_rewrite Apache module configured and mod_rewrite enabled in httpd.conf configuration file. If you are running Drupal on a different type of server, check the links section below (just above the Comments section of this page) to see if there might be something that addresses your server configuration on a different page.
Before enabling clean URLs in the Drupal configuration screens (see below), you may need to prepare your server for clean URLs to work. There are two ways to prepare your server for clean URLs to work in Drupal. If you have complete control of your server, for example because you run your own server, are installing a development site on your personal computer, or have a dedicated server hosting account, then you should enable clean URLs in the httpd.conf file for better performance and security. However, if you have a shared hosting account (at DreamHost, BlueHost, HostGator, GoDaddy, 1and1, et al.), you will not be able to modify the httpd.conf file and should use the Drupal .htaccess file instead.
Enabling Clean URLs in Drupal
Note: The standard Drupal installation contains a sample .htaccess file which supports clean URLs. It is easy to miss copying this file, because of the leading "dot". So before trying to enable Clean URLs, make sure this file exists in your Drupal installation.
Drupal 6.x
In Drupal 6, the installer tests for compatibility with Clean URLs as a part of the installation process. If the installer was not able to run the test successfully at install time, you can later follow the instructions below for Drupal 5 to get Clean URLs working. There is one minor difference: Drupal 6 will run the clean URL test automatically when you navigate to the Clean URLs configuration page and will show the results, in place of giving you a link to run the test manually.
Also note that even if Clean URLs are successfully enabled at install-time, if you have a dedicated server you may still want to follow the steps below to enable the more efficient httpd.conf rewrite method for clean URLs. If you choose to do that, you might want to turn off Clean URLs while you are working on the server.
Drupal 5.x
Here are the steps necessary to enable Clean URLs in Drupal 5:
- Goto the administer >> site configuration >> clean urls section of the administrative interface.
- Look for the paragraph that reads as follows:
This option makes Drupal emit "clean" URLs (i.e. without ?q= in the URL.) Before enabling clean URLs, you must perform a test to determine if your server is properly configured. If you are able to see this page again after clicking the "Run the clean URL test" link, the test has succeeded and the radio buttons above will be available. If instead you are directed to a "Page not found" error, you will need to change the configuration of your server. The handbook page on Clean URLs has additional troubleshooting information. Run the clean URL test.
- Click on the Run the clean URL test link at the end of the above paragraph.
- If the test is successful, set Clean URLs to "enabled" and save the configuration. If the test is not successful, use the steps below to fix your server configuration and try again.
Prior to Drupal 5.x
For Drupal versions prior to Drupal 5, there is no automatic Clean URLs test or link. Instead, you can test manually by typing in the Clean URL for your settings page: http://www.example.com/admin/settings (where www.example.com is replaced by your hostname). If this results in seeing the settings page, and no errors, then Clean URLs are safe to enable, and you can do so with the setting on this page. If there is an error, follow the instructions below to configure your server.
Error recovery
Enabling "Clean URLs" when your server is not properly configured (i.e. if the Clean URLs tests described above fail) can make it difficult to navigate back to administration pages to undo your mistake, because all the Drupal-generated menus and links will have URLs that do not work. If you find yourself in this situation, you can return to the administrative settings page by typing in the URL in the 'non-clean' form: http://www.example.com/?q=admin/settings for the admin settings page in Drupal 4.x, or http://www.example.com/?q=admin/settings/clean-urls to get to the Drupal 5 or Drupal 6 Clean URLs settings page. Once there, you should be able to reset to not using Clean URLs.
There are additional instructions for recovering from malfunctioning Clean URLs the Handbook page Unset clean URLs.
Server configuration for Clean URLs on a dedicated server, with httpd.conf
Enabling clean URLs on a dedicated server involves these steps:
- Enable mod_rewrite for Apache. You can talk to your web host or consult the Apache documentation for mod_rewrite to get more information on how to do this. At a minimum, this will involve making sure that mod_rewrite is enabled for your installation of Apache.
To test if mod_rewrite is available in Apache2, you can type the following at a command prompt, to list all installed Apache modules:
apache2ctl -MOn some systems this command may be:
apachectl -MIn the output, check to see if the
rewrite_moduleis included in the list of modules.If the rewrite module is not in the list, it will have to be either compiled-in or made available as a loadable module. Generally speaking, you can tell Apache to load the module by including
LoadModule rewrite_module modules/mod_rewrite.so
AddModule mod_rewrite.c
in your Apache configuration file (see below for information on the configuration file). Be sure to uncomment AddModule mod_rewrite.c, if it is in your configuration file but has been commented out. The following may work to enable the module without editing any files:a2enmod rewriteNote that these approaches may not work for all combinations of operating system and Apache server -- consult the Apache documentation that came with your Apache software for the correct syntax.
Remember to restart Apache for the new configuration to take effect.
- The next step is to locate the appropriate Apache configuration file for your site. Depending on your server configuration, the appropriate Apache configuration file could be httpd.conf, a virtual-host-specific file (vhost.conf), a specific site file (e.g. "default"), or apache2.conf. They are usually located in
/etc/httpd/conf,/etc/apache2, or a sub-directory; if not, try the command:
find /etc -name httpd*
to find the file if it is located elsewhere in your file system.If you do not have write permissions to these files, and Clean URLs are not working out-of-the-box for you, you may have to ask your systems administrator or hosting provider for help. You may still be able to read these configuration files to troubleshoot a little however.
- The next step is to copy or include the Drupal-specific settings directly into your configuration file. There are instructions here for how to include the Drupal directives in your configuration file. Consult the .htaccess file in Drupal page for examples of rules, such as the following:
<Directory /var/www/example.com>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>Make sure that you are looking at the .htaccess file for your major version of Drupal (i.e., 7.x, 6.x, 5.x). If
Note: If you do not want to put the rewrite rules in your Apache configuration file, you can still simply use the Drupal .htaccess file (as you would if you were on shared hosting). You will need to have the Allow Override directive set in your Apache configuration file (this will allow local .htaccess overrides on your site):
AllowOverride All
AccessFileName .htaccessRead Behind the scenes with Apache's .htaccess for a thorough review of .htaccess. You may also find it helpful to view samples of Apache 2 AllowOverride directives.
Note Regarding MultiViews: Apache supports a feature called "MultiViews" (more generally: "Content Negotiation"), which allows navigation to your pages without the need for file extensions. For instance, if you had a file called "evaluation.txt", a MultiViews-enabled site could access this file with the URL "example.com/evaluation". While MultiViews can be a handy feature when used knowingly, it can cause problems when Drupal's Clean URLs are enabled. Unless you know what you're doing, you should not use MultiViews if you plan to use the Clean URLs feature of Drupal. However, MultiViews is not enabled in a default Apache installation, so it is likely that this note will not apply. Consult the Apache documentation for further information about MultiViews.
Server configuration for Clean URLs on a shared server, with .htaccess
The standard Drupal installation contains a sample .htaccess file which should be sufficient to get Clean URLs running. It is easy to miss copying this file, because of the leading "dot". So before trying to enable Clean URLs, make sure this file exists in your Drupal installation.
If you have this file installed, but Clean URLs still do not work, you can try some of the troubleshooting suggestions below. If you still cannot get Clean URLs to work, contact your hosting provider.
Fixing problems
Check .htaccess is even being used
Apache needs to be explicitly told to respect the instructions in your sites .htaccess file. This is off by default, though most hosts will have turned it on. That is what the AllowOverride All directive above does - it makes .htaccess start working.
To check if your host is currently even reading your .htaccess, you can (temporarily) add some garbage string to the file in an attempt to break it. Your site should immediately start returning a "500 Server Error" when you load a page from that directory due to this misconfiguration. (Remove the garbage string immediately.)
If you do this, and your site does not break - then .htaccess is being ignored and you will not be able to use clean URLs until you get support from your hosts, or enable it in httpd.conf as described above. Some hosts allow you to enable this option through their site management control panel, so look there first.
RewriteBase setting
The main configuration option which may need to be changed for your site is the RewriteBase. This can be specified in the Drupal .htaccess file or in the httpd.conf file, depending on where you are putting the Drupal rewrite directives (see above). By default, the RewriteBase setting is commented out of the Drupal .htaccess file, and that works well for many configurations.
If you are having trouble getting Clean URLs to work, you may need to change this setting. For example, if your Apache DocumentRoot is /var/www/ (i.e., /var/www/index.html is what is displayed when you point your browser at http://www.example.com/) and your Drupal installation is installed in the subdirectory /var/www/mysite/, then the RewriteBase could be set to
RewriteBase /mysiteand that might help. In some configurations, setting
RewriteBase /will allow clean URLs to work.
Multi-site
RewriteBase works when your Drupal installation serves only one site, or when all the sites it serves are in the same subdirectory of their domains. For example,
RewriteBase /will work for the following sites:
http://www.example.com/
http://www.example2.com/
http://www.example3.com/
RewriteBase /mysitewill work for the following sites:
http://www.example.com/mysite
http://www.example2.com/mysite
http://www.example3.com/mysite
However, if your sites are in different subdirectories, RewriteBase will not work. You will need to create a special rule for each subdirectory. For example, your Drupal installation may serve the following sites:
http://www.example.com/
http://www.example.com/mysite
In order to enable clean URLs for both sites, you will need to add
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/mysite/(.*)$
RewriteRule ^(.*)$ /mysite/index.php?q=$1 [L,QSA]before the existing rewrite rules.
Location of index.php
For some server configurations, another change to the Drupal .htaccess file may be necessary. Find a line that looks like this, near the end of your Drupal .htaccess file:
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]You may need to replace index.php with the URL path to your Drupal installation's index.php file (only the part after the base URL). For instance, if your site's home page URL is http://example.com/subdir/, you might need to use /subdir/index.php instead of index.php. If your site's home page URL is http://example.com/, you might need to use /index.php instead of index.php. This is necessary on some, but not all server configurations.
Create Even Cleaner URLs with the Path Module
Using Clean URLs will cause Drupal to generate URLs in the form "http://www.example.com/node/83." In order to change the 'node/##' portion of the URL to something more like 'news/june-1st-news' a site will need the Path module enabled. See the Path module handbook page for more information on using the path module.

Need apache VirtualHost setup for rewrites to work
Just thought that It would be good to mention that you need to have a VirtualHost setup in your apache config.
When I did fresh install of apache on ubuntu server 8 I had to first make a static link to the rewrite.load file
as admin I ran the command
a2enmod rewriteHad to setup a virtual host for my domain name
NameVirtualHost *:80
<VirtualHost *:80>
ServerName yourdomainname.com
ServerAlias *.yourdomainname.com
DocumentRoot /var/www/drupal6/
</VirtualHost>
restart apache
/etc/init.d/apache2 restartLitte ontribution
Scenario:
Fedora Core 4
Apache 1.3
Multisite (Many web applications, 4 moodle sites and drupal)
web directory /www/moodle1 - /www/moodle2 - /www/webappx - /www/drupal - etc)
I just added next lines at the server httpd.conf file and it worked
# for drupal, added by achandia<Directory "/www/drupal">
AllowOverride All
</Directory>
restart apache
/etc/init.d/httpd restartI hope this helps.
@ch
Yes, setting up a virtual host makes 'clean URLs' work.
I set a virtual host as follows and now I can have 'Clean URLs' work.
For some reason, the same setup did not work with Drupal-6.17.
<VirtualHost *:80>ServerAdmin abc@xxx.org
DocumentRoot /opt/lampp/htdocs/drupal-6.16
ServerName drupal.xxx.org
ErrorLog logs/xxx.org-error_log
CustomLog logs/xxx.org-access_log common
</VirtualHost>
<Directory "/opt/lampp/htdocs/drupal-6.16">
RewriteEngine on
RewriteBase /drupal-6.16
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
clean url on multisite
on a drupal regular multisite clean url will not work without .htaccess in each project root, so make sure to copy also .htaccess
/.htaccess
/anothersite/.htaccess
Hope that helps anybody
Clean URL .htacccess with DreamHost, GODaddy and Bluehost
DreamHost users have to use following code in .htaccess for clean URL
I haven’t test on godaddy and blueshot, but they should work the same
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
godaddy settings
As a further update on anyone using godaddy:
I have a deluxe hosting with many sites. Using ftp, I edit the .htaccess file for the directory I am loading drupal in. At the bottom, remove the comment symbol to show the following
<IfModule mod_rewrite.c>RewriteEngine on
#
# big bunch of comment lines
#
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
The line with favican.ico was there. Even though I am using a subdirectory, I didn't need to change any of the lines. Save and check clean url's. Should work right away.
Mac OS X 10.5 (client not Server)
To turn on clean URL's on Mac OS X 10.5.6:
Add
AccessFileName .htaccessto /private/etc/apache2/httpd.conf
Then dependant on where you have installed drupal either:
If you've installed it in /Library/WebServer/Documents
In /private/etc/apache2/httpd.conf change the AllowOverride directive to
AllowOverride Allwithin the
<Directory "/Library/WebServer/Documents">block.If you've installed it in /Users/<username>/Sites:
In private/etc/apache2/users/.conf change the AllowOverride directive to
AllowOverride Allwithin the
<Directory "/Users/<username>/Sites">block (it's likely this will be the only block in this file).Finally in the .htaccess file in the drupal directory uncomment the line
#RewriteBase /drupaland change the /drupal to what ever is appropriate for your install
Good luck!
for the last step. this
for the last step. this worked for me
RewriteBase /~[username]/ouroakland/htdocs
but this did not:
RewriteBase /Users/[username]/Sites/ouroakland
the leading slash is required.
Glad it worked for you, but ...
... but what finally worked for me was:
httpd.conf (mine is at /opt/local/apache2/conf since I'm using a MacPorts installation)
DocumentRoot "/Users/elisevanlooij/Sites"
<Directory "/Users/elisevanlooij/Sites">
~/Sites/Drupal6/.htaccess (I also have a Drupal5 install in Sites)
RewriteBase /~elisevanlooij/Drupal6Thank you Dilby for taking the time to write out these instructions for your fellow 10.5 users. I'm really happy to finally have this working.
Thank you
Thank you so much your and dilby's comments finally made things clear for me, fixed my problem, and allowed me to turn on Clean URLs.
Mac OS X 10.6 (client not Server)
All I needed to get CleanURLs (Drupal 6.17) going on my Snow Leopard (PHP5.3) setup was:
In /etc/apache2/httpd.conf change the AllowOverride directive from None (default) to All :
AllowOverride All
And in the .htaccess file in the drupal directory uncomment the line
#RewriteBase / <== whatever is appropriate for your setup
Hope this might help someone else.
1And1 Solution
For 1And1 with PHP 5, only change needed is:
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
to:
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
Found solution here: http://geeksandgod.com/forum/drupals-clean-urls
Using Clean URLs and WAMP2
Windows
c:\wamp\bin\apache\Apache2.2.11\conf\httpd.conf
uncomment
#LoadModule rewrite_module modules/mod_rewrite.so
will have
LoadModule rewrite_module modules/mod_rewrite.so
Uniform Server 4.0 (Mona)
This edit is also required in uniserv 4.0.
Edit the file
[drive][path]\Uniform Server\udrive\usr\local\apache2\conf\httpd.conf
Change line 194
#LoadModule rewrite_module modules/mod_rewrite.so
to
LoadModule rewrite_module modules/mod_rewrite.so
See http://wiki.uniformserver.com/index.php/Installing_Drupal_on_4.0-Mona for more tips.
Versions prior to 4 already have the rewrite_module line uncommented.
UBUNTU
I wanted to share my problem with getting clean urls to work in ubuntu. I couldn't find any info on how to do this, but finally I pieced it together and it is actually very simple. Just do the following:
1)enable rewrite module on apache.
a2enmod rewrite
(to disable type a2dismod rewrite)
2)Set directory permission.
You must find the file that sets permission of each directory for apache. In my case it was /etc/apache2/sites-enabled/000-default
edit the page so that the directory that you will be using to serve webpages has "AllowOverride All". My file contains the following:
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
3)Just restart apache and it should be working:
/etc/init.d/apache2 restart
Great Job!!!
In testing Ubuntu 9.10 I've set up 2 different servers 1) Ubuntu w/XAMMP and 2) Ubuntu with LAMP install from the server installation...both were different in getting this to work. Thanks.....
Thank you
Great!!! I'm using Linux Mint Helena (based on Ubuntu 9.10) and this works...
Thank you again.
PapayaMedia.com
Ubuntu 10.04 LTS + Apache2 +PHP5 + MySql 5.1.41 + Drupal 6.16
I followed Method 2 http://drupal.org/node/134439
You have to enabled the rewrite module(mod_rewrite)
sudo a2enmod rewriteMy Drupal Installation serves one site which is in the subdirectory Drupal6
Hence my site address is http://localhost/drupal6
1st step
With Apache version 2, the httpd.conf has been deprecated (actually mine is empty ), and the new file is located at: /etc/apache2/apache2.conf
So, in the command line type:
sudo /etc/apache2/apache2.confCopy paste following lines in the directory section, if it doesn't exist, just copy paste the lines at the bottom , and save the file.
<Directory /var/www/localhost/drupal6>AllowOverride All
</Directory>
2nd step
sudo nano etc/apache2/apache2.cnfCopy paste the following lines and save the file
RewriteLog "/var/log/apache2/rewrite.log"RewriteLogLevel 3
3rd step
sudo nano /etc/drupal/6/htaccessUnder rewrite rules make sure the following lines exist otherwise copy paste them , make sure to replace /drupal6 in line 4, /drupal6 in line 7 and /drupal6 in line 8 by your site's directory otherwise it won't work. Save changes.
<IfModule mod_rewrite.c>RewriteEngine On
RewriteRule "(^|/)\." - [F]
RewriteBase /drupal6
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/drupal6/(.*)$
RewriteRule ^(.*)$ /drupal6/index.php?q=$1 [L,QSA]
</IfModule>
4th step
Reload apache
sudo /etc/init.d/apache2 reload5th step
Enable url rewriting at /admin/settings/clean-urls
save changes
alaca
Easier
Easier way?
https://help.ubuntu.com/community/Drupal
Example, my install is /var/www/html/
cd /var/www/htmlsudo gedit .htaccess
# 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 /html
Seems to work for me.
My Situation
I installed Drupal (6.9) in a subdomain using GoDaddy hosting. I was initially unable to use clean URLs.
First I changed the RewriteBase directive to "/subdomainfolder". That didn't work.
Next, I added the "AllowOverride All" and "AccessFileName .htaccess" directives to the .htaccess file but that only produced a 500 error.
Lastly, I commented out the "AllowOverride All" and "AccessFileName .htaccess" directives and added a "/" in front of "index.php" in the line reading "RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]" to make it "RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]"
That worked.
subpath in Debian
In Debian, when you want to use clean URLs with a subpath you can do it in the following way:
<Location /mysubpath><IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/usr/share/drupal6/(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
</Location>
This will give you a Drupal site at http://example.com/mysubpath/
Make sure to update the RewriteRule line with whatever version of Drupal you happen to be using.
subpath in Debian Lenny Backports (maybe etch/ubuntu too?)
See the page http://drupal.org/node/781412 for up-to-date Debian configuration for Lenny backports and Squeeze (Drupal 6.16).
pro-freedom
Apache no longer needs AddModule
AddModule used to be used to control the order in which you enabled the different Apache modules. However as of Apache 2.0 the directive AddModule is no longer required (pop to the apache site for a full explanation) so there's no need for
AddModule mod_rewrite.c
unless you're running an older Apache.
Network Solutions Fix
Network Solutions hosting is a complete disaster, but if you're stuck with it the following post helped me get Clean URLs working in a D6.10 install.
http://drupal.org/node/11861#comment-18597
This only applies to the shared unix hosting package, where PHP is run through CGI.
In short, you need to create a php.ini file in the /cgi-bin folder at the root of your Network Solutions directory.
Fill the php.ini with the settings from the IfModule mod_php5.c section of your Drupal install's .htaccess. You can't just cut and paste because the ini format is parsed differently than .htaccess.
In D6.10, your php.ini file should looks like this:
register_globals = offmagic_quotes_gpc = 0
register_globals = 0
session.auto_start = 0
mbstring.http_input = pass
mbstring.http_output = pass
mbstring.encoding_translation = 0
Then you need to set BOTH the RewriteBase in your .htaccess file, and the $base_url variable in your site's settings.php file.
Go back to the clean urls admin page, and you should be able to flip the switch.
Some have reported that you need to comment out the Options +FollowSymLinks setting in your .htaccess file, but I haven't had to do so.
It's also worth noting that you won't be able to make it through the install process without errors without setting up a php.ini file as described above to disable register_globals.
Clean URLs on DotEasy Hosting
I just installed Drupal 6.10 in a subdomain hosted by doteasy.
I read for hours about Apache Modules and mod_rewrite in particular only to discover that getting clean URLs to work is very easy in this situation.
Maybe this will save you some time:
1. Make sure you include the .htaccess file with the rest of your Drupal files in the directory on the server. Obvious to some, but .htaccess files are hidden by default in OSX and not included in a standard drag-and-drop transfer from your local directory to an FTP client. Installing Drupal is 100% possible without the .htaccess file but enabling clean URLs in a shared hosting environment is not.
2. Uncomment line 101 of the .htaccess file -- the one that has the "RewriteBase /" command
------------------
website | livejournal
I use Aplus.net hosting and this worked for me!
Uncomment line 101 of the .htaccess file -- the one that has the "RewriteBase /" command
Thanks so much!
17
Tip on .htaccess
I moved an existing site to another server, but the clean URLs no longer worked. After spending umpteen hours trying to troubleshoot it, I found the problem. Apache has multiple references to the .htaccess file. The first is a "default" setting as follows (even though I had changed the AllowOverride to All, it had no effect because it was overridden later [see below]):
<Directory />Options FollowSymLinks
AllowOverride None
</Directory>
The second reference actually overrides the default setting:
<Directory "/var/www/html">AllowOverride None
</Directory>
After changing that setting, my clean URLs were all bright and shiny again! :-) Probably a no-brainer for those who spend a lot of time in the httpd.conf file, but it escaped me because I kept referring to the default setting.
Getting clean URLs working under Windows running Apache2
I got this from http://quillem.com/node/506 and it worked:
In your httpd.conf uncomment
#LoadModule rewrite_module modules/mod_rewrite.so
and add the following in httpd.conf with Directory config block, replace the path with the path of your Drupal installation:
Options FollowSymLinks
AllowOverride All
RewriteEngine On
Note: there is no "AddModule mod_rewrite.c" needed
Thank you, the RewriteEngine
Thank you, the RewriteEngine On is what I needed. This was a problem I encountered on a WAMP even though I had the rewrite module in httpd.conf enabled. I assumed the engine was On. Wrong. =0
This also works for 1and1 customers!!!
Great Job!! This also works for 1and1 customers!!!
Clean URL .htacccess with DreamHost, GODaddy and Bluehost
dannychang - December 26, 2008 - 21:34
DreamHost users have to use following code in .htaccess for clean URL
I haven’t test on godaddy and blueshot, but they should work the same
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
-------
mod_rewrite on Mac Os X in vhost.conf...
mod_rewrite & Virtualhosts on Mac OS X Leopard Server
After much trial and error (mostly error). I finally got Clean URLs working on my Mac server. However let me start off by station that my Leopard server does not run the stock Apache, but one that I built form the ports tree because the stock one is a rpita!!! when it comes to php customization. Plus Apple is rather slow to keep up with basic security updates on UNIX ports.
RewriteEngine off<Directory "/Volumes/Data/web/SOMESITE.com/public/">
AllowOverride Options
<IfModule mod_dav.c>
DAV Off
</IfModule>
Options All -Includes -ExecCGI +MultiViews -Indexes
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
</Directory>
Thanks to this note I found on the Zend Framework Page regarding mod_rewrite which suggests placing a forward slash before index.php. I did try the tag but that did not work so I moved things around and well struck pay dirt. I shall test this on one of my FreeBSD web servers tomorrow morning and if it work I'll make another note.
I hope this saves someone hours of headaches from not having to knock their head on a wall...;-|
<VirtualHost *>ServerName beta.SOMESITE.com
ServerAdmin admin@example.com
DocumentRoot "/web/SOMESITE.com/public/"
DirectoryIndex "index.php" "index.html"
CustomLog "/web/SOMESITE.com/logs/access_log" "%h %l %u %t \"%r\" %>s %b"
ErrorLog "/var/log/apache2/error_log"
ErrorDocument 404 /error.html
<IfModule mod_dav.c>
DAVLockDB "/var/run/davlocks/.davlock100"
DAVMinTimeout 600
</IfModule>
<IfModule mod_mem_cache.c>
CacheEnable mem /
MCacheSize 4096
</IfModule>
RewriteEngine off
<Directory "/web/SOMESITE.com/public/">
AllowOverride Options
<IfModule mod_dav.c>
DAV Off
</IfModule>
Options All -Includes -ExecCGI +MultiViews -Indexes
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
</Directory>
LogLevel warn
ServerAlias beta.SOMESITE.com
</VirtualHost>
Cheers,
Mikel King http://twitter.com/mikelking
http://olivent.com
http://jafdip.com
http://mikelking.com
ISAPI Re-write
Thought I'd report back.
It's been several hours now and 5 re-boots of my server just in case it was services not starting of something. I must have visited 20 websites and checked everything I could.
Finally I decided to download the trial version instead of the free 'Lite' version. Bam! Working straight away - I guess they don't want anyone to go without paying. I'm sure they deserve their money. I just wish someone would pay me for the hours of banging my head against a wall.
I'm very glad it's working. I just feel a bit flat after so much effort and so many angry thoughts running through my head.
Adding rewrites to Mac Leopard Server
1. make sure
mod_rewrite.sois checked on in Server Admin2. if Server Admin on your system allows you to check "Allow All Overrides" in the Apache Options for your site, you're done. Otherwise...
3. edit
/etc/apache2/sites/[0000_your_site_info.conf](where is a filename corresponding to the site you have created in Server Admin -> Web -> Sites) and make the following change:<Directory "/Library/WebServer/Documents">entry (if you haven't changed your site's root, otherwise look for the entry with your specified root)AllowOverride NonetoAllowOverride AllFix for Omnis Hosting
To get clean urls working with my Omnis hosting account, I had to remove the following from the standard .htaccess file:
# Follow symbolic links in this directory.
Options +FollowSymLinks
Clean URL on drupal 6.14
Hi
I have a similar problem but when I transfer the site to the final server, it shows me a similar message so what I did was
- check if the rewrite module is enabled
prompt$apache2ctl -Mand as it was enable I add this code to my httpd.conf to allow clean URLs
# Various rewrite rules.<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /home
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
this works for me. the /home is for my drupal installation location
drupal 6.14
Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.7 with Suhosin-Patch
Ubuntu Clean URLs setup
Hi. I get irritated every time I have to do this, so writing a note for me and for everyone else that it might help:
Setup LAMP on Ubuntu. Create symbolic link to phpmyadmin (just by the way because its annoying to remember):
Setup instructions here: http://www.ubuntugeek.com/howto-install-lamp-server-in-jaunty.html
Creating link:
sudo ln -s /usr/share/phpMyAdmin /var/wwwInstall mod_rewrite:
sudo a2enmod rewriteAdd this to conf (sudo gedit /etc/apache2/httpd.conf):
<Directory /var/www/fridays>RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
AllowOverride All
</Directory>
Restart Apache:
sudo /etc/init.d/apache2 restartHope that works straight away for someone. Took me 2 hours to work out.
Bruce
Corrected rewrite rule for multi-site
Under "Multi-site" above, we find the following prescription:
In order to enable clean URLs for both sites, you will need to add
RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/mysite/(.*)$
RewriteRule ^(.*)$ /mysite/index.php?q=$1 [L,QSA]
before the existing rewrite rules.
The
$1in the last line should be%1, since we want to take the back-reference from the last RewriteCond, not from the RewriteRule itself.If we use
$1, we get an extra "mysite/" in the query part of the URL. As an example, for /mysite/target-url we get:/mysite/index.php?q=mysite/target-url
With
%1, we instead get/mysite/index.php?q=target-url
which is what we want.
Rewriting root to existing subdirectory
Having installed Drupal v6 in a subdirectory /drupal, I wanted to "move" the installation to the root, without having to move all the files up a level. After finding some great posts online, this could be done with a .htaccess file and a few other tweaks, mainly sourced from a post "Getting started with Drupal 6 in a subfolder". In a nutshell:
1. I created a new
.htaccessfile in the root, containing:RewriteEngine onRewriteRule ^$ /drupal/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ drupal/$1 [L,QSA]
2. I deleted the existing file in the root,
index.htm, so that it would not be found and served up. You might also need to remove, if it exists,index.php(actually I renamed the files on the server, so that if I encountered a problem, I could rename it back, and continue with the old site)3. In
sites/default/settings.php, I changed the commented line to:$base_url = 'http://www.mydomain.com'; // NO trailing slash!D6: Auto test failed
I struggled an hour before understanding that the test which allows to enable clean-urls which was failing.
I was modifying my configuration and was refreshing http://localhost/q=admin/settings/clean-urls , unable to enable it.
After validating that mod_rewrite was enabled, I guessed this auto-test was failing, and tried to reload my page at http://localhost/admin/settings/clean-urls . The test succeeded and I was able to enable clean urls :p
Here's another fix
I just spent hours trying to figure this out - and finally got it to work trying something I haven't seen listed elsewhere:
I had been opening the httpd.conf file in dreamweaver - editing per instructions found here - then closing it. Turns out, Dreamweaver was adding something to the mix unbeknownst to me. Opening the httpd.conf file in notepad, editing and saving out that way suddenly made everything work. Here are the only changes I made:
1) Per an earlier message in this thread, I removed the hash (#) mark before the following in the .htaccess file:
RewriteBase /
2) I removed the pound sign/hash mark/# before the following in the httpd.conf file:
LoadModule rewrite_module modules/mod_rewrite.so
After saving each of those files, (again, editing in notepad as opposed to dreamweaver) I simply restarted "all services" and refreshed the "clean urls" page on my site and was able to enable clean urls.
Note: I made no other changes; other suggestions/coding found in this thread were unnecessary for my setup (wamp, windows xp home, apache 2.2.11, php 5.3.0, drupal 6.15)
a fix that worked
trying to get the Clean URLs page at Home > Administer > site configuration to work properly so the radio button for ENABLED would work. I finally got- "your server has been successfully tested to support this feature"
using Windows XP, WampServer2.0h.exe, MySQL 5.1.33, PHP 5.2.9-2, Apache 2.2.11, Drupal 6.15
working on my local computer:
I found the file named httpd.conf at C/wamp/bin/apache/apache2.2.11/conf
Opened this file using Notepad and removed the # marks from the line that reads - LoadModule rewrite_module modules/mod_rewrite.so
Then I added to httpd.conf as stated above while changing the directory as follows to read:
<Directory /var/www/sites/default>RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
Mar
like it
it work perfect for me. thanks for the solution.
thank you
Thank you!
I would have never suspected that using http://localhost/?q=admin/settings/clean-urls reported a wrong result, while http://localhost/admin/settings/clean-urls succeeded!
For this reason I did not understand your instructions immediately. So more clearly, what I did after restoring mod_rewrite is just changing the URL in the browser.
Clean URLs on Sourceforge
For projects hosted on Sourceforge, you will need to uncomment the following line from the standard .htaccess file
RewriteBase /and then copy .htaccess in your /home/groups/f/fo/fooproject/htdocs folder, where "fooproject" is your project UNIX name.
Clean URLs on multisite installation
My Scenario:
Using multisite in that I have a main installation of Drupal on my server in /drupal
Created 3 sites to run off a single codebase by doing the following:
Create the following sub directories (note the final directory should match the domain name without the "www"):
* /drupal/sites/siteone.co.uk
* /drupal/sites/sitetwo.co.uk
* /drupal/sites/sitethree.co.uk
Created a MySQL database for each site and copied the default.settings.php file from drupal/sites/default into each of the directories created above.
Renamed each instance of default.settings.php => settings.php and input the corresponding database login details so siteone.co.uk could connect to its own database and sitetwo.co.uk could connect to its own database and...
Visited www.siteone.co.uk/install.php to install and repeated for the other two sites.
Read many articles that claimed clean urls would only work if I made a reqrite rule for each site in the main .htaccess file.
No need for that on my server. The only two changes I made were to declare the drupal code directory like so:
### Declare drupal directory ###
RewriteBase /drupal
And changed:
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] => RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
- note the "/" in the latter.
Clean URLS is now working on all three sites.
Through my testing, I must have broken the .htaccess file so I re-downloaded drupal, copied the .htaccess file and made just those two changes and it worked.
My file is attached as a .txt here if you need it as a reference point.
Example
Hi,
the text mentions it removes the query parameter, but it does not say what is the expected format of your URL for a regular node.
I'm finding that to be, for a default install (e.g. no additions to the URL like the country name ../es/.., etc. ) :
domain.com/node/nodenumber
such as
domain.com/node/1234
just as the nodes on the drupal.org site.
I'm looking for SEO friendly URLs for a blog or forum. Is this module addressing this problem?
Thanks
La escupidera - Blog de xmariachi
Blog de Xmariachi|Poesía dadá
I've got a problem with my Clean URLs
Mostly, they work. However, on
http://www.jacobkking.com/
On the main page, if you scroll to the bottom and click one of the "next page" links, the rewrite rule doesn't take effect. Instead of getting
http://jacobkking.com/page=1I get
http://jacobkking.com/node/?page=1which produces a broken link.
I'm hosted on GoDaddy and these are my .htaccess settings:
RewriteEngine onRewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
I'm smart enough to know that I'm dumb.
Hi, Please, anybody have Idea
Hi,
Please, anybody have Idea how to get It running on Windows+ IIS?
tks
Wils
Never is to late to re-factory =D
Drupal over DotNetPanel
Hi all you guys,
I've trying this for about a week unsuccessfully (maybe I need a different point of view). My hosting is SeekDotNel, which provides PHP hosting over DotNetpanel (I mean any kind of .NET based manager over IIS), but it parse .htaccess a little bit weird b/c Rewrite* options are not enough for it, I mean it throws the following error:
DotNetPanel IIS Modules Error
AuthName directive not found.
File: C:\HostingSpaces\mainsite\maindomain\wwwroot\.htaccess
So I thought, in order to remove alert, it requires a kinf of authentication configuration like the following:
AuthType None
AuthName Unrestricted
But it neccesarilly demands AuthUserFile (AuthUserFile /sec.db) and my site turns in something unaccessible.
Any ideas? Thanks in advance.
hints for nginx?
I have problem setting up clean url for my nginx web server. I tried some hints here and there on blogs, but with no success. Regarding that a considerable portion of drupal sites run on nginx servers, I am wondering why the instruction is not included here yet, and I wish someone can do so.
Cheers
Drupal 6.17 gives me a problem with Clean ULRs
I was able to enable Clean URLs under Drupal 6.16.
But I can't under Drupal 6.17 with the same settings.
<Directory "/opt/lampp/htdocs/drupal-6.17">AllowOverride All
</Directory>
I also tried:
<Directory "/opt/lampp/htdocs/drupal-6.17">RewriteEngine on
RewriteBase /drupal-6.17
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
There must be some change in 6.17 that makes this problem.
What could that be?
u can see
u can see post " a fix that worked " above this post. I work D6.17 and this ok w me.
6.17
6.17 worked for me, out of the box. I had problems initially because I hadn't copied the .htaccess out of the drupal-6.17 dir and into my new site...
FC10, apache 2.2.14
If you can't get the clean
If you can't get the clean urls to work, you may just be missing the simple user path in your .htaccess file This is almost always the case.
instead of RewriteBase /
you need to add the ~user (user being the name of your cpanel account)
RewriteBase /~user
for those on hostgator you can find this on your welcome/setup email its very simple to because it is 99.9% going to be your cpanel username. Don't forget the ~ before it. You should not have to have any additional path after this just the /~user
Probably being dense but...
I have Drupal 6.17 and Wampserver 2.0 running on XP. I've also installed the Token, Path and Pathauto modules and tried some of the things listed but Clean URLS is still disabled. I'm not a programmer and don't really know my way around Apache, PHP, or MySQL but I have programmed and can follow instructions and edit files successfully. Could anybody give me an idiots guide to enabling Clean URLS?
Cheers
Gus