Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm having a problem with an .htaccess file on a newly installed Ubuntu server running Apache2.

The .htaccess file in the directory where the WordPress files are located isn't being take into account when the server loads pages. There isn't an AllowOverride statement in the apache2.conf file, but the default is All, and it doesn't change anything if I include one.

I've tried including the contents of the local .htaccess file in a section. I've also tried this:

<Directory /var/www/mydomain.com/html>
AllowOverride All
</Directory>

I also tried changing all instances of AllowOverride in /etc/apache2/sites-available/default (which are all set to Noneby default) to All.

But I've had no luck.

Not sure how to solve this one.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

You need to ensure the mod_rewrite is enabled:

sudo a2enmod rewrite

Then restart apache

share|improve this answer
    
Actually, I'd checked: it was already enabled. But I eventually found what was causing it! See below. –  Donald Jenkins Dec 10 '11 at 19:33

I worked out what it was since I opened this thread: there were two issues that I would have thought would crop up in any vanilla LAMP setup installed according to the Media Temple Knowledgebase article (which was what I used to set up the (ve) server).

Firstly, it was the rewrite module. It appeared as though my .htaccess files weren’t being read by the server because a rewrite module has to be enabled: this seems to be the default on a fresh install such as the one I just carried out. Who knew?

Enabling the module is pretty simple: I just needed to make a symbolic link to the rewrite.load file from the mods-available directory to the mods-enabled directory (all found, in this instance, in the apache2 directory, at /etc/apache2).

Ran the following:

$ cd /etc/apache2/mods-enabled
$ ln -s /etc/apache2/mods-available/rewrite.load rewrite.load

Secondly, I concluded I also need to change all instances of AllowOverride in /etc/apache2/sites-available/default (which are all set to None by default) to All(see this article which explains the issue).

Finally was the question of how to apply the rules. I actually chose to delete my .htaccess file and place all its rules in a <Directory> section in http.conf (which is now a separate file still called in apache2.conf, and which I'll use to include all my customizations), because setting AllowOverride to None and relying on apache2.conf for everything induces an increase in speed as the server no longer has to check for an .htaccess file at every level before loading a page. I then deleted the .htaccess, set AllowOverrideto None, and the rules still loaded fine.

share|improve this answer
    
Note that the a2enmod command under ubuntu creates the symbolic link for you. It is always good to understand what is going on behind the scenes, but if you do, then using the command will avoid any type errors –  Paul Dec 10 '11 at 21:58
    
Yes, I realised that eventually. Thanks! –  Donald Jenkins Dec 11 '11 at 2:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.