So I'm attempting to configure a server with Apache 2.4. I've got most things working, except for the .htaccess file. I've read through a couple posts/guides and I'm almost certain that my config is correct.

I've got rewrite_module enabled in my http.conf

LoadModule rewrite_module libexec/mod_rewrite.so

In my VirtualHost I have the following directory directive.

<Directory "/var/www/mysite/web">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted

And this is my .htaccess file.

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI}  !(\.png|\.jpg|\.gif|\.jpeg|\.bmp|\.css|\.js|\.js.map)$

# otherwise forward it to index.php
RewriteRule . index.php

I have a feeling that the .htaccess formatting for rewrites might have changed in 2.4, but I can't seem to find any decent examples saying how it should be looking. Is what I have still valid and if not, how should I go about changing it?


  • Perhaps RewriteRule . index.php should be RewriteRule .* index.php? Or do you really want to match only "any single character?" See Apache 2.4 documentation for Regular Expressions for more guidance. – Colt Jun 30 '16 at 23:05
  • @Colt I've tried various different ways, nothing seems to work. At this point, I'm not even sure that the .htaccess is even being referenced/read. – SynackSA Jul 4 '16 at 18:43
  • what directory is the .htaccess file in? – Colt Jul 4 '16 at 18:47
  • it's located in /var/www/mysite/web – SynackSA Jul 4 '16 at 18:48
  • 1
    "formatting for rewrites might have changed in 2.4" - nothing changed with regards to these directives between Apache 2.2 and 2.4. Unfortunately, without knowing specifically what is "not working", this question is near impossible to answer. You may also need to show your entire VirtualHost. What happens? Do you get any errors? Is .htaccess being processed at all? Why use .htaccess when you have access to the server config/VirtualHost? (If the "formatting/syntax" had changed you would probably get a 500 error.) – MrWhite Mar 30 '17 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.