I'm a newbie .htaccess and regex. I have a script that works locally but when I upload it to a live server it causes an infinite loop. How can I fix this? On the site when you load http://subdomain.example.com
if you are unauthenticated it takes you to http://subdomain.example.com/auth/
for a login form, else it displays the contents of http://subdomain.example.com/index.php
. It works fine locally but when I upload on a live server, it cannot find auth.php so it redirects to the index page and because the user is not authenticated it sends to auth.php thus the infinite loop. When I test my .htaccess from here http://htaccess.madewithlove.be/ the results are as shown below. Please advice. Please help. Thanks.
This is my file
Options +FollowSymLinks -MultiViews -Indexes
<IfModule mod_rewrite.c>
DirectoryIndex index.php
RewriteEngine On
RewriteBase /
# remove php extensions (only for GET method)
RewriteCond %{THE_REQUEST} ^GET\ /(.+)\.php(?:\?|\s) [NC] #This variable is not supported: %{THE_REQUEST}
RewriteCond %{REQUEST_FILENAME} -f #This variable is not supported: %{REQUEST_FILENAME}
RewriteRule ^ %1/? [L,R=301] #This rule was not met because one of the conditions was not met
# don't touch other existing files/folders
RewriteCond %{REQUEST_FILENAME} -f [OR] #This variable is not supported: %{REQUEST_FILENAME}
RewriteCond %{REQUEST_FILENAME} -d [OR] #This variable is not supported: %{REQUEST_FILENAME}
RewriteCond %{ENV:REDIRECT_STATUS} \d #This variable is not supported: %{ENV:REDIRECT_STATUS}
RewriteRule ^ - [L] #This rule was not met because one of the conditions was not met
# force trailing slash
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f #This variable is not supported: %{DOCUMENT_ROOT}/$1\.php
RewriteRule ^(.+?[^/])$ $1/ [L,R=301] #This rule was not met because one of the conditions was not met
RewriteCond %{DOCUMENT_ROOT}/$1.php -f #This variable is not supported: %{DOCUMENT_ROOT}/$1.php
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ $1.php?a=$2&id=$3 [QSA,L]#This rule was not met because one of the conditions was not met
#rewrite path to file eg http://example.com/auth/recover to http://example.com/auth.php?a=recover
RewriteCond %{DOCUMENT_ROOT}/$1.php -f #This variable is not supported: %{DOCUMENT_ROOT}/$1.php
RewriteRule ^([^/]+)/([^/]+)/?$ $1.php?a=$2 [QSA,L] #This rule was not met because one of the conditions was not met
# rewrite extensionless php files
RewriteCond %{DOCUMENT_ROOT}/$1.php -f #This variable is not supported: %{DOCUMENT_ROOT}/$1.php
RewriteRule ^(.+?)/$ $1.php [L] #This rule was not met because one of the conditions was not met
# finally, if not found
RewriteRule . index.php [L] #This rule was met, the new url is http://subdomain.example.com/index.php
</IfModule>