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.Note that this 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.
- 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 providor 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>
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 .htacces for a thorough review of .htaccess; this other site has samples of Apache 2 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
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/
And
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.
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/number' 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.
It also worked for CentOS 5
It also worked for CentOS 5
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
Have a problem!
I have 3 lanquge web site, in my .htaccess I wrote:
< IfModule mod_rewrite.c >
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
< /IfModule >
And it is working just for Home page! In ather pages it looking like this:
www.mysite.com/en/node/node/16 or www.mysite.com/en/node/node/node/16
and should be the - www.mysite.com/en/node/16
Is somebody Know how to solve this problem? Please Help.
infinitely expanding URLs
Hi, iwm7. Just saw your question. You've probably already solved it by now, but in case anyone else is having the same problem...
it sounds to me like this is not an .htaccess problem, but a relative links problem. That is, in your home page if you are linking to "node/16" instead of "/en/node/16" the link will work properly the first time you use it, but each subsequent time you will get an additional node/ in the URL. the solution is to avoid using relative links; instead use either /en/node/16 or the full http: URL.
XAMPP Clean URLs
I futzed around on here for a while trying to get a solution to Clean URLs issue in XAMPP. I eventually got a video from lullabot (search: XAMPP on their site and you will be guided to a video that actually details how to set up a WAMP installation. WAMP is the same as XAMPP just a different brand and a little different operation). The key for Clean URLs is the mod_rewrite module in Apache. It must be activated before you install Drupal. This is absolutely key. Using WAMP this is very simple. Watch the Lullabot video for a showing of how it's done. XAMPP is a little more difficult and requires actual editing of the httpd.conf file contained in the apache/conf/httpd.conf. Simple uncomment the LoadModule mod_rewrite line (located right after the proxy module lines). I may not have quoted the line correctly here, but it contains mod_rewrite and is the only one that does so. Then restart XAMPP (or if you like me and using a Windows Machine, I actually recommend a reboot just to be extra sure) and then install Drupal. The Clean URL test should fly off without a hitch! Let me know if you have any other questions.
Cheers,
Cole
Apache2 mod_rewrite
I found a much more understandable and apt for ubuntu 8.04/apache2 mod_rewrite activation procedure here:
http://www.lavluda.com/2007/07/15/how-to-enable-mod_rewrite-in-apache22-...
I have the impression the procedure explained in the drupal.org pages is not correct for ubuntu/apache2.
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>
Thank You
I was running 3 sites from one host on Godaddy and had clean urls working on only my main URL but not the other three sites and used changed all .htaccess files on the other three sites and it allowed me to finally enable clean urls. Thanks alot for the info.
Thanks!
These settings works great on Dreamhost! Thank you for sharing!
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.
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
this works too
The only change I made for http://www.tapinferno.com/ was to uncomment the line
RewriteBase /
in .htaccess.
I was able to set Clean URLs after that
Ajay Gautam
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
Dev Sites and Clean URL
I could be way off base here but it seems to me, based on forum chatter, that one might consider not turning on clean urls when working on a dev site on a local computer. I've been reading about the problems with absolute and relative paths once the dev site is uploaded to live hosting space. I'm interested in knowing if others concur. If so, we might want to consider adding this info to the tutorial? Or a cautionary note?
good tip
That's a good point, techywoman. In my (limited) experience, if your development site's configuration is significantly different from your live site's, for example IIS vs. Apache, then you are better off not tinkering with CleanURLs on the dev site. However, if their configuration is (or can be made) the same, it is worth the time to make sure your modules, etc. work properly. Some modules, notably Ubercart, do not work without CleanURLs.
I forgot to move my .htaccess
I forgot to move my .htaccess file during initial install, so I'm looking here to fix the issue.
After moving the .htaccess file into the root directory, I'm getting the "Your server has been successfully tested to support this feature" message. But the Clean Urls selector is still disabled - I can't enable it. (And the paragraph cited in section 3.2 above was never present)
I've tried resetting to default without success, and I've even tried disabling and re-enabling the path and pathauto modules (for no reason other than that the word path is in them)
Notes:
- Dreamhost shared hosting
- Clean install of 6.9 in new subdomain
- the .htaccess already contained all of the lines noted in the prior Dreamhost comment above except for the favicon line
this is odd
I've made no changes since my initial post. However, I tried loading the Clean URLs admin page into another browser tab. I was able to click the "Run the clean URL test" link before it automatically went to the success message and voila, now the selector is usable.
I reloaded the admin page mutliple times and even cleared the cache before this without success.
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.
I have emailed my hosting
I have emailed my hosting company asking if mod_rewrite is enabled and they have told me the following:
We have received your email. We have checked on our server mod_rewrite Apache module is enabled. You can install drupal on your both accounts. Please check the same and let us know for the further assistance if at all you need.
BUT the cleanurls 'enabled' button is greyed out and it says the following: "Your system configuration does not currently support this feature. The handbook page on Clean URLs has additional troubleshooting information."
What do i need to do to get it to work? the htaccess file has not been changed at all as yet
Many thanks
I just used the following
I just used the following solution on my host provider web-mania (who are very accommodating by the way)
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
Works brilliantly!
thanks
Try saying the name of your
Try saying the name of your hosting provider, perhaps someone reading this uses the same one.
It's also worth checking to see if your hosting provider has member forums and/or a wiki. Drupal is widely used, so unless you're using a very new small provider it's likely someone else has already figured this out. And, of course, if nobody has already asked the question in your provider's forums, ask! At the very least, an unsatisfactory outcome will alert others.
[Update] glad you fixed it! Sorry we crossed in the post -- I got called away from the keyboard in the middle of responding!
It would be interesting to
Matte, It would be interesting to know why it needed that slash, in other words since it wasn't going to your root directory where was it going? I'm no mod_rewrite guru, but I imagine RewriteBase / would have had the same effect and might even be a better solution if you add further rules in the future.
Perhaps an expert can comment?
Really confusing
There is no clear distinction between each drupal version procedure. It's very confusing.
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.
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.
Some example .htaccess files, please!
My personal experience with .htaccess and mod_rewrite is:
- The apache command language is not really "intuitive".
- The explanations on apache.org are not really intuitive either, and so far they failed to give me a clear mental model. Some explanations can be misunderstood, etc.
- I am happy if it works, but still lack a deeper understanding of the apache command language.
- I still use try-and-error if something with .htaccess doesn't work.
- The example .htaccess file included in a fresh Drupal install is quite complex, compared to other projects (Zend Framework, for instance).
- The example .htaccess assumes that Drupal is sitting in web root. I have it in a subdirectory. The example .htaccess didn't work for me, even after
Having said all that, I would like to propose the following:
Publish different example .htaccess files: One that can be used having Drupal installed in web root, and another with Drupal installed in a subdirectory. Maybe even more alternatives, such as different OSes, if that makes any difference. Explain when to use one or the other, and explain the different statements.
Some explanations are already in the existing example .htaccess, but I think some more would do good.
Thank you!
donq
Worked on 1&1 for me too
I'm using Drupal 6.10 and once I added the / in front of index.php like you did for GoDaddy, CleanURLs started working for me as well.
Just a wee bit more info - I have Drupal at the root, and then a new DEV version in a subfolder (which is the one CleanURLs wasn't working for). I didn't change the root .htaccess (it doesn't have RewriteBase set and isn't able to use CleanURLs). I am hosting with 1&1 on their basic Linux package. I had RewriteBase set to /mysubfolder and kept it that way.
Thanks for the help!
Clean URLs have been working
Clean URLs have been working fine for me until I started experimenting with Wiki implementations.
It seems there is something in my Drupal set-up set resets my clean URL setting from enabled to disabled.
Does anyone know why this might happen?
As soon as the URL goes to disabled all the freelinking and wikidness stops performing.
Thanks for all and every suggestion to resolve this.
Nice solution for
Nice solution for drupal...
And does anyone know how to get rid of this "?" marks in wordpress posts? and how to write several words instead... That would be definitely helpful info for me...
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.
How to disable rewriting for some subdirectory?
Hi,
Rewrites works well on my drupal site (http://projects.mycompany.com). I created a subdirectory, named 'otherstuff' under the root of the site, and I don't want to apply rewriting rules to it and all in it. How to exclude this directory from rewriting?
Also, how to arrange this situation:
projects.mycompany.com is a virtual host, and I defined several Locations in it, controlled by 'DAV svn'. As a result http://projects.mycompany.com/project_1/svn/ is a legal address. These locations are physically outside the directory of the Drupal site. But after enabling rewriting http://projects.mycompany.com/project_1/svn/ becomes forbidden. How to deal in this situation?
Ivan
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
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.
PHP Warning: PHP Startup: Unable to load mod_rewrite
Hi, I enabled clean URLs and am getting a PHP warning iwhich is clogging up my stderr_log file:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613+lfs/mod_rewrite.so' - /usr/lib/php5/20060613+lfs/mod_rewrite.so: cannot open shared object file: No such file or directory in Unknown on line 0
I run a hosted site and do not have direct access to Apache configuration. My Drupal installation is in /www/mysite, so I seem to understand that I should modify the RewriteBase in my .htaccess as explained in above para. "Optional: RewriteBase. Only do this if you are having trouble".
Do you think I'm correct? These are the RewirteBase rules currently: which and how should I change? Thank you.
# 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]
Clean URLs work but can't edit or create new content
We have Clean URLs running -- no issues there.
When we go to edit current pages or create new ones we get redirected to a 404 - Page Not Found which is on our hosting side not our internal 404. When we turn clean URLs off we can magically edit and create content.
We have configured the .htaccess file and done everything we have found on drupal.org. We have contacted our hosting company and they say everything is configured properly.
All other modules appear to work properly when Clean URLs are on.
Anyone got the answer? I will give you a piece of candy....
Clean URLs work but can't edit or create new content
if you all setting are correct check this out.
In .htaccess file line 22 is like
ErrorDocument 404 "The requested file favicon.ico was not found.
change it to
ErrorDocument 404 "The requested file favicon.ico was not found."
thanks all
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
Changed Clean URLs form with Firebug then saved config
On my godaddy multisite, which shares code but uses different dbases, Clean URLs were enabled OK on my sub-sites, but not on the primary site. Htaccess was OK, and the test said Clean URLs are supported, but the 'Disable' and 'Enable' radio buttons were both 'disabled' (unavailable), so I couldn't change the setting to 'Enabled'.
I used Firebug Inspect to select and delete the 'disabled="true"' attributes on the radio buttons, chose the 'Enabled' option, then saved configuration OK. :)
DRUPAL AMAZON EC2 AMI clean url
I'm using the default configuration of this Drupal Amazon AMI, from this project http://drupal.org/project/ec2ami i have followed the steps of this tutorial But I'm still not able to make CLEAN URL works. please i need some help of the community on this .. thank you very much,. AMI ID: ami-2a8a6d43
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]
-------
what next? - set up rewrite + added to httpd.conf, tell drupal?
Hello, I'm using: Ubuntu 9.04 to run a localhost development site.
I properly added the mod_rewrite to apache2, then added the following into httpd.conf
# for drupal, added by jzacsh
<Directory "/www/ubercart">
AllowOverride All
</Directory>
<Directory /var/www/ubercart>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
then restarted apache
sudo /etc/init.d/apache2 restartnow how do I tell my site that clean-urls should work? (or should I just visit that particular admin page, and it should be "click-able", the radio button that is...) - anyways, the radio button isn't clickable, and I don't know what I should do to tell my site that the proper config is set-up now. thanks in advance!
UPDATE:
I see that the first part (allowoverride) isn't necessary in my case, because I'm writing my stuff directly into the httpd.conf. Still though, I don't know why its not working.
NEVERMIND:
I'm sorry everyone, just another example of me not reading every last sentence of the article ^ - I simply needed to append my subdirectory to the RewriteBase /
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
mod_rewrite & Virtualhosts on FreeBSD 7.2 w/ Apache2.2
mod_rewrite & Virtualhosts on FreeBSD 7.2 w/ Apache2.2
I have just confirmed that this also works on FreeBSD 7.2 if there is anyone out there with some Linux boxes that could give it a go I'd be keen to know if it works on them as well.
At some point I shall give it a go on the stock Apache that comes with Mac Os X Server...
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>
Cheers,
Mikel King http://twitter.com/mikelking
http://olivent.com
http://jafdip.com
http://mikelking.com