Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

closed as off-topic by muru, Pilot6, Charles Green, David Foerster, Eric Carvalho Jan 31 at 18:26

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – muru, Pilot6, Charles Green, David Foerster, Eric Carvalho
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
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

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

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