This is my .htaccess file:
RewriteEngine On
DirectoryIndex index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^login login_reg.php [L] [NC]
RewriteRule ^(.+) redirect.php?shortcode=$1 [L] [NC]
What I want is for anything other than '/login' and root '/' to be redirected to redirect.php with the request_url (the bit after the slash) being substituted as the shortcode GET variable.
However, the file above gives me an error: "The page isn’t redirecting properly"
Few issues:
login
will also match rewritten login_reg.php
RewriteCond
will be applicable to immediate next RewriteRule
only hence last rule is rewriting everything infinitely.[...]
You can use these rules in your .htaccess:
DirectoryIndex index.php
RewriteEngine On
RewriteRule ^login/?$ login_reg.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.+) redirect.php?shortcode=$1 [L,NC,QSA]