apachemod-rewriteinfinite-loop

Apache redirect infinite loop


I want to have a redirect from https://example.com/app/my.page to https://example.com/app/my.page?login=INTERNAL

but unfortunately I go into an infinite loop

I have some staging script for httpd.conf configuration, so the syntax for the config is not the standard one, but I can show you this:

pattern="^(/app/my.page)"
substitution="$1?login=INTERNAL" 
flags="[R=302]"

Solution

  • Please try this solution in order to perform the redirect and avoid inifinite loops.

    RewriteEngine On

    RewriteCond %{REQUEST_URI} ^/app/my.page$

    RewriteCond %{QUERY_STRING} !login=INTERNAL

    RewriteRule ^(.*)$ /app/my.page?login=INTERNAL [L,R=302]