Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I`m using apache2 on ubuntu 11. I want to secure my wordpress site with .htaccess rules, but I understand that it is preferable to put the rules in the apache config file (httpd.conf).

If I understand correctly, the virtual site config file (under /etc/apache2/sites-available) is the config file for my wordpress, and not the main apache config.

I want to put Mod_rewrite rules on my site, but when I put it in the config file of the virtual host, apache won't start (file to read the rules).

So, do I have to use .htaccess, or can I use the virtual host config file.

(this is what I want to accomplish: http://journalxtra.com/websiteadvice/wordpress-security-hardening-htaccess-rules-4025/)

share|improve this question
Stack overflow is probably a better place to get support on editing Apache config files. –  Amanda Jan 25 '12 at 21:36
This question should be moved to stackoverflow, wordpress, servers or any other more related site for this question. Even if using ubuntu the question is more for another more related site than askubuntu. –  Luis Alvarado Jan 28 '12 at 18:26

2 Answers 2

Honestly, though it is technically "preferable" to put rule sin your apache config file, with something like a WordPress site, you're better off just using a .htaccess file, not least because almost everyone else who is hosting wordpress is doing it on a commercial web host where they don't have access to their Apache config files, so all the guidance out there assumes you're editing a .htaccess file.

share|improve this answer

You should never put any site specific configuration in httpd.conf - use the site config file in /etc/apache2/sites-available instead.

If Apache complains you did something wrong. Most statements you can put into a .htaccess file need to go into a section when you put them into the site config file - it's common error to forget this.

If you can't figure it out ourself please post the site config file that causes the trouble and the error messages you get when you try to start Apache.

share|improve this answer

Your Answer


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.