.htaccess with RewriteRule


I’m moving a domain from an old server to one with Hestia on it and I’m running into a problem with the .htaccess that is needed for the site to operate. I want to rewrite everything to index.php which will deal with the request. This is the .htaccess that works on the existing server:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?q=$1 [L,NC,QSA]

However, I’m getting a 404 on everything other thank index.php with the new Hestia based server. .htaccess just doesn’t appear to be doing anything / not being used.

Is there something I need to do to add support for the .htaccess files and more specificaly the RewriteRule command?

I did see this thread and tried that, but wasn’t able to see any difference.

Many thanks,

Hi @theallan,

As Nginx is taking care of php, you should modify nginx conf files for your domain.



try_files  $uri @fallback;

to something like this:

try_files  $uri $uri/ /index.php?q=$args @fallback;

Save files, restart or reload nginx and check again. If it works as expected, you should create a new nginx proxy template, made the changes in that template and assign it to your web domain so the changes won’t be overriden in a future update.

1 Like

Hi @sahsanu,

Many thanks for your reply. I should have thought of looking into that. I’ve just been digging around and it looks like the way Hestia is setup by default it will use nginx to server a bunch of static files based on extension, but everything else, gets passed to Apache.

What it appears I was missing was that I needed RewriteEngine on in my .htaccess file. With that, it works. The previous server must have that in the main Apache config somewhere.

So all good and I can carry on :slight_smile:


1 Like