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
]]>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.
]]>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
]]>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>
]]>