How can I enable clean URLs without HTACCESS?

I've read and had verified that HTACCESS is a performance hit on Drupal. So I don't want to do clean URLs that way.

Has anyone been sucessful in this? I'm using UBUNTU 8.04 and Drupal 6.19.


7 Replies

Put the rewrite rules into your virtual host configuration file. It'll probably need to go inside a block. That way, the rewrite rules will be loaded and parsed only once when the server starts up.

Thanks - could you expound on that a touch?

I take the same lines out of htaccess and put them in with Apache file? I'm on Ubuntu 8.04 and Apache2. I see a couple configuration files:




Those are all in the /etc/apache2 directory. Is that even the right place to look for my server configuration file?

Did you put all of your website files in /var/www? If so, the file is


There'll be a section that begins with

You put your rewrite rules inside those tags.


Thanks - could you expound on that a touch?

Read this.

There is a common misconception that .htaccess files must be used, be in reality anything in .htaccess can go in your configuration file.

> When should I, and should I not use .htaccess files?

Allowing .htaccess files will make Apache look for them upon every access to your server. Since parent directories are searched as well, this will take some (small) amount of time, and can impact your server's performance. For a better explanation, see HtaccessGotchas. (move that explanation here?)

Should use

.htaccess files should really only be used when you cannot directly edit the main configuration files.

Should not use

You should not use .htaccess when:

* 1. you have access to edit the main server configuration file(s).

2\. server performance is of concern to you.

3\. untrusted people host websites on the server. (See How can I prevent users from using .htaccess? and How can I control what users can do with .htaccess files? (How to link to headings of this doc????))</list></quote></r>

Thanks for the feedback!

I have only one Drupal site and one instance of Apache2 installed in the normal places.

I took the rewrite rules out of .htaccess and put them in the directory area of /etc/apache2/sites-available/default but it didn't work. bummer! Here are the rewrite rules I tried:

Set one:

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]

Those didn't work so after reading another article i tried:

RewriteEngine on

RewriteCond %{SERVER_PORT} ^80$



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

And of course was reloading and restarting Apache each time. These didn't work for me. Any tips on what I might have wrong? THANKS.

Are there any other files in the sites-available folder? Are you using a control panel that might load configuration files from different locations?

I don't think %{SERVER_PORT} would be relevant here. The port is usually specified in the tag.

Try adding a slash between %{DOCUMENTROOT} and %{REQUESTFILENAME}.

You might have to play with a RewriteBase configuration.

Check /var/log/apache2/error.log for any errors.

What else…?

Thanks for the reply…

There is one other site specified in sites available that I just added. "" for use with munin monitoring.

I'm just so new to this stuff I don't even know what to mess with when it comes to these rewrite variables. I have a very vanilla drupal 6.19 installation. One site, one domain name, etc.


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct