Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 wont 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:

Thank you! asaf

share|improve this question

You can use the rewrite rules in the site's virtual conf file under the directory Site's Available. Do something like this:

    <VirtualHost *:80>

    RewriteEngine On
    Rule one
    Rule two


The important bit is to enable the RewriteEngine before the the rewrite rules.

Not sure but I don't think all the rewrite rules will work in that context (I should test them and update the post). Try adding different blocks between server restarts (install Webmin for easy admin of the server) then let me know which blocks are interfering with the server.

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.