Make full website URL to become lowercase
I am having a website with URL where subfolders vary from all uppercase to all lowercase. What I would like to happen is to make whole website URL lowercase once loaded. Even if the user changes it to whatever he wants, it will revert to lowercase once page refreshed.
I tried using what ChatGPT said but this only gives me 500 Internal error. He tried many different variations of this and with http and https and yet all fail in the same way. He also tried with haccess file but it didn't work. Actually, it works for first subfolder, but fails for all others in the path.
<cfsetting showdebugoutput="Yes">
<cftry>
<cfset requestURL = GetHttpRequestData().headers["host"] & GetHttpRequestData().headers["x-original-uri"]>
<cfset lowercaseURL = LCase(requestURL)>
<cfset segments = ListToArray(lowercaseURL, "/")>
<cfset lastSegment = ArrayLast(segments)>
<cfif CGI.QUERY_STRING NEQ "">
<cfset lowercaseURL = "#Replace(lowercaseURL, lastSegment, LCase(lastSegment))#?#CGI.QUERY_STRING#">
</cfif>
<cfset lowercaseURL = ReplaceList(lowercaseURL, "/index.cfm", "", "ALL")>
<cfif LCase(CGI.SCRIPT_NAME) neq LCase(lastSegment) AND LCase(CGI.SCRIPT_NAME) neq LCase(ListLast(CGI.SCRIPT_NAME, '/'))>
<cfheader statuscode="301" statustext="Moved Permanently">
<cfheader name="Location" value="#lowercaseURL#">
<cfabort>
</cfif>
I
