.htaccessmod-rewriteredirect-loop

Rewrite which was working with Apache 2.2 doesn't work on Apache 2.4


I have to migrate my company website to a new Cloud VPS and I'm getting a redirect loop because of the rewrite which was just working fine on old server. It works for some page like Login which was dedicated to be only work with https.

I read a lot already about this and I tried, nothing helped me.

Here is the original rewrite from .htaccess file

    php_flag session.auto_start Off

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]

I found some similar question on this Stack Overflow also - I tried it and it did not work.


Solution

  • Shorten your rule patterns to just ^ and change their flags to just END.