Clean URLs
The first thing we can do to improve our URLs is to get rid of the pesky ? character. Our URLs will change from:
/?q=node/17
to:
/node/17
which, although not descriptive, at least looks like a regular URL.
Changing this is simply a matter of enabling a feature called Clean URLs. However, there is something you need to do first.
Enabling mod-rewrite
Clean URLs relies on some technology in your webserver (mod-rewrite) which automatically converts URLs based on configurable rules. You need to know how to enable this, and what to do if it accidentally gets turned off.
mod_rewrite is a module in Apache. If you are not using an Apache based server, see below. Drupal uses it to convert /node/17 into /?q=node/17, while all the time making the user think they are visiting /node/17.
You don't need to know how mod_rewrite works, or how to set it up. You only need to enable the module, Drupal will use it automatically.
If you are running your own Apache server, refer to the documentation to find out how to enable this module.
If you are using shared or managed hosting, ask your hosting company for advice. They should be able to help you, it is a fairly common requirement Many hosts allow you to switch it on via your control panel.
If you are not using an Apache based server, it is still possible to use Clean URLs, but you are not making your life any easier. Refer to drupal.org for help on equivalent functionality for alternative server technologies.
Enabling Clean URLs
Go to Navigation | Administer | Site configuration | Clean URLs. Click Enabled and push the Save configuration button.
Note that Drupal 6 will prevent you from enabling Clean URLs if you do not have mod_rewrite enabled. The Enabled button will be grayed out.
If mod_rewrite is turned off
If you enable Clean URLs then your Drupal site is dependent on mod_rewrite to work at all. That is why Drupal makes it impossible for you to enable Clean URLs until mod_rewrite is available.
But what happens if mod_rewrite gets accidentally switched off? This isn't a frequent occurrence, but it happens sometimes.
The best course of action, obviously, it to enable mod_rewrite again, straight away. If this isn't possible (eg if you are using a host who takes three days to get around to fixing things), you might want to turn off Clean URLs temporarily, to get your site up and running again. Problem is, the Navigation menu is using clean URLs, which don't work.
When you try to click Navigation | Administer | Site configuration | Clean URLs, it fails! Well fortunately, the old style URLs still work – yes, if you want you can type in /?q=node/17 and find node 17, even with Clean URLs enabled. As it happens, the clean URLs config page is located at:
/?q=admin/settings/clean-urls
If you happen to find that you are not logged in as admin when disaster strikes, you can also find the login page at:
/?q=user
and this will always work.
