• Hello everyone,

    According to several guides I’ve read, it’s best to insert your rewrite rules in the apache config/virtual hosts file rather than the .htaccess file. Doing so will allow apache to perform better and make it more secure.

    Question: How can I automate or tell WordPress to write the rewrite rules in my virtual hosts file? I am trying to avoid the laborious task of having to copy the .htaccess file’s contents and paste them into the virtual hosts file every time a new plugin or theme is installed/modified.

    Please let me know if there’s a more efficient workaround!

    Thank you for all your contribution, courteous help, and relentless support! You guys are magical and sensational!

    God bless the team in perpetuity!

    All my best,

    Joe

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Under no circumstances should WordPress have the ability to write into apache config files. That way lies madness.

    Yes, it’s best to put all the rewrites into the httpd config because they only need to be parsed once, but the time is really minimal and unless you have a very heavily trafficked site, your optimization efforts are best put elsehwere.

    Thread Starter rebornhairppp

    (@rebornhairppp)

    Hi Steve,

    Thanks for responding so quickly!

    I completely understand. Yes, it’s true the rules need to be parsed only once if I wasn’t going to enable or disable certain features of a plugin. Every time I make a tiny change, I have to first remember to enable .htaccess and then modify the virtual hosts file.

    Given my concerns, I guess I have to eat the bullet.

    Question #1: Once I transfer all my rewrite rules under the <Directory root path> block, I should disable .htaccess to prevent apache for having to read it?

    Question #2: I have an https permanent redirect in my port 80 virtual host file. Do I include the rewrite rules in the port 80 or port 443 virtual host file? I am thinking it’s the port 80 file.

    Thanks again Steve!

    All my best,

    Joe

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Second question first: This is how I set up my config files for my sterndata[dot]com website: https://gist.github.com/sterndata/55bac4f1d833421203cff7816e2f5276

    First question last: WordPress will continue to write .htaccess files. If you use this in your virtualhost config, apache will ignore it:

    <Directory /path/to/wordpress>
       AllowOverride None
    </Directory>
    Thread Starter rebornhairppp

    (@rebornhairppp)

    Cool thanks again Steve!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How To Force WordPress To Use Apache Virtual Host File Rather Than .htaccess’ is closed to new replies.