I'm a client on Interserver's LiteSpeed/5.0.17 Enterprise system
Note: foobar.org is Not my actual website name.
The following rules are supposed to redirect everything not HTTPS or not starting with www. except robots.txt and anything with directory /ExternalConnect to https://www.foobar.org/%{REQUEST_URI}
It works as expected when I test at http://htaccess.madewithlove.be/ and mostly works on my site, but when tested on my site with www.foobar.org/ExternalConnect/ext.php (does not exist) it redirects with a 301 then throws a 404 for file 404.shmtl Expected result is 404 for /ExternalConnect/ext.php with no redirection.
When tested live on my site with https://foobar.org/ExternalConnect/Ext.php (exists) it redirects with a 301 then executes the script Expected result is a 200 with no redirection
When tested live on my site with https://www.foobar.org/ExternalConnect/ext.php (does not exist) it redirects throws a 404 /ExternalConnect/ext.php as expected
I've also tried RewriteCond %{REQUEST_URI} !(^/robots.txt$|/ExternalConnect) without success for the above. Also the robots.txt logic works as expected. So essentially this rule is not working RewriteCond: %{REQUEST_URI} !/ExternalConnect
.htaccess Ruleset
Note: foobar.org is Not my actual website name.
The following rules are supposed to redirect everything not HTTPS or not starting with www. except robots.txt and anything with directory /ExternalConnect to https://www.foobar.org/%{REQUEST_URI}
It works as expected when I test at http://htaccess.madewithlove.be/ and mostly works on my site, but when tested on my site with www.foobar.org/ExternalConnect/ext.php (does not exist) it redirects with a 301 then throws a 404 for file 404.shmtl Expected result is 404 for /ExternalConnect/ext.php with no redirection.
When tested live on my site with https://foobar.org/ExternalConnect/Ext.php (exists) it redirects with a 301 then executes the script Expected result is a 200 with no redirection
When tested live on my site with https://www.foobar.org/ExternalConnect/ext.php (does not exist) it redirects throws a 404 /ExternalConnect/ext.php as expected
I've also tried RewriteCond %{REQUEST_URI} !(^/robots.txt$|/ExternalConnect) without success for the above. Also the robots.txt logic works as expected. So essentially this rule is not working RewriteCond: %{REQUEST_URI} !/ExternalConnect
.htaccess Ruleset
Code:
RewriteCond %{REQUEST_URI} !^/robots.txt$
RewriteCond %{REQUEST_URI} !/ExternalConnect
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^foobar\.org [NC]
RewriteRule ^(.*)$ https://www.foobar.org/$1 [R=301,L]
PS I also tried the following but also does not work as expected
RewriteCond %{REQUEST_URI} !^/robots.txt$
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^foobar\.org [NC]
RewriteRule "!ExternalConnect" "https://www.foobar.org/%{REQUEST_URI}" [R=301,L]
Last edited by a moderator: