Jump to content

Lowercase all file/folder names


son
 Share

Recommended Posts

To combat the issues arrising from users entering folder and/or file names with uppercase letters (I only use lowercase) I included a file at top of web pages as:

$trailed = $_SERVER['REQUEST_URI'];	if (preg_match('/[A-Z]/', $trailed)) 	{  	$trailed = strtolower($trailed);  	header('HTTP/1.1 301 Moved Permanently');   	header('Location: http://'. $_SERVER["SERVER_NAME"] . $trailed);  	exit;	}

However, it shows 404 error when I uppercase a letter for testing for example. I also tried:if (preg_match('/[[:upper:]]/', $trailed)) but also does not work. I am open to any solution. Tried few via .htaccess, but also no luck (and no access to config file)...Any ideas?Son

Link to comment
Share on other sites

Just a couple things to try.Try echoing the value of 'http://'. $_SERVER["SERVER_NAME"] . $trailed and see if it's what you expect. Try entering that value directly in your URL bar and see how your server responds.

Edited by Deirdre's Dad
Link to comment
Share on other sites

Just a couple things to try.Try echoing the value of 'http://'. $_SERVER["SERVER_NAME"] . $trailed and see if it's what you expect. Try entering that value directly in your URL bar and see how your server responds.
Thanks, Deirdre's Dad. I tried this earlier on and this showed the link ok (as long as I entered it correctly in lowercase obviously). Not sure what is not working in my script correctly...Son
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...