• Home
  • Systems
  • Networking
  • WordPress
  • Web
  • Geekery

Analysis and Review

Move WordPress .htaccess to Virtual Host for Improve Performance

April 10, 2016 by Kurt Turner

Moving you WordPress .htaccess file to your vhost configuration files will indeed improve the performance of apache. By configuring your virtual host to point to your .htaccess file, you’re telling apache where to load the configuration versus having to maintain all .htaccess changes each time your wordpress blog updates, including plugins.

  • Caveat, each time any .htaccess file changes you need to reload Apache.
  • Caveat, if you remove a .htaccess file you’ll need to remove the directive including it in the virtualhost configuration file.

Here’s how to speed up Apache by removing AllowOverRide All –

[code]

<VirtualHost *:80>
ServerAdmin webmaster@website.com
DocumentRoot "/var/www/website"
ServerName website.biz
ServerAlias *.website.biz
ErrorLog "/var/log/apache2/website-error_log"
<Directory /var/www/website/>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Include /var/www/website/.htaccess
</Directory>
<Directory "/var/www/website/wp-content/cache/">
Include /var/www/website/wp-content/cache/.htaccess
</directory>
<Directory "/var/www/website/wp-content/uploads/wpcf7_captcha/">
Include /var/www/website/wp-content/uploads/wpcf7_captcha/.htaccess
</directory>
<Directory "/var/www/website/wp-content/themes/NewTheme/cache/">
Include /var/www/website/wp-content/themes/NewTheme/cache/.htaccess
</directory>
<Directory "/var/www/website/wp-content/blogs.dir/9/files/wpcf7_captcha/">
Include /var/www/website/wp-content/blogs.dir/9/files/wpcf7_captcha/.htaccess
</directory>
</VirtualHost>

[/code]

BONUS TIP: use the below grep to find all .htaccess files within your web root!

[code]find /var/www/ | grep ‘.htaccess'[/code]

Now if you’re installing wordpress for thte first time or you’re not done tweaking the configuration I’ll recommend that you use the .htaccess with allowoverride set to all until you’re done setting things up. But once the website is done and all set up with all the plugins you’re going to use you should disable allowoverride and let apache load the .htaccess directive from within the virtual host configuration.

Filed Under: Systems

Latest and Greatest

Apache vs Nginx for WordPress

Certbot Lets Encrypt And WordPress MU Multi-Site

How To Find and Replace Multiple File in MS Word

How To Get Stretch Res on Windows 10 AMD Radeon For Game Play

This is the ASUS Chromebox we've been running for 2 years as our "brain" for our home grown digital display kiosk.

DIY Digital Signage Bulletin Board or Kiosk

© Copyright Analysis And Review · All Rights Reserved ·