Posts

Showing posts from March, 2016

Apache - RewriteRule in htaccess vs httpd.conf

Typically Apache’s RewriteRule sets from mod_rewrite go in .htaccess files, but sometimes you have a good reason to put them in your general server config instead:

your httpd.conf orapache2.conf file (or a file you Include from one of those). If you’ve done this before, you’ve probably been surprised that it didn’t work quite the same. So while this works in .htaccess: RewriteEngine On RewriteCond%{REQUEST_FILENAME} !-f RewriteRule . /index.php [L] Putting the same thing in your VirtualHost doesn’t work at all: <VirtualHost *:80> ServerNameexample.com DocumentRoot /var/www/example/ <Directory /var/www/example/> Allow From All </Directory> RewriteEngine On RewriteCond%{REQUEST_FILENAME} !-f RewriteRule . /index.php [L]