How to change letters in namespace and make it case sensitive.

Avatar
  • Answered
Hi, I want the site map should take capital ,small letters, special character in it and display it accordingly in site map, how do i can change its namespace. please tell, I want respond immediately.
Avatar
JacobIMH
Hello, On Linux server's all folder and file names are case-sensitive after the domain name. So for instance trying to access:

http://example.com/test.htm

Or:

http://EXAmple.com/test.htm

Will pull up the same page. However if you change the case of the file or folder such as:

http://example.com/Test.htm

This would try to pull up a completely different file with a capital T in the filename by default. It is not recommended to make your files case sensitive due to search engines and possible duplicate content, as they could index Test.htm, TEst.htm, TESt.htm etc... and believe that each page should be a separate entity. Also if your scripts are looking for a particular case of a file and you're forcing the server to be non case sensitive this could also lead to unexpected issues. If you really wanted to go ahead and allow for any case to be type in for your file names, then if you have root access to your server, you can modify the Apache configuration for your site and add these rules to the <VirtualHost> entry for your domain:
RewriteMap tolowercase int:tolower
RewriteRule ^(.*)$ ${tolowercase:$1}
Otherwise you'd need to implement these set of rules in your .htaccess file, and again while this works, it would not be recommended over simply choosing a consistent naming scheme and then sticking with all folders/files either being all lower case or not:
Options +FollowSymlinks
RewriteEngine On

RewriteRule ![A-Z] - [S=27]

RewriteRule ^([^A]*)A(.*)$ $1a$2
RewriteRule ^([^B]*)B(.*)$ $1b$2
RewriteRule ^([^C]*)C(.*)$ $1c$2
RewriteRule ^([^D]*)D(.*)$ $1d$2
RewriteRule ^([^E]*)E(.*)$ $1e$2
RewriteRule ^([^F]*)F(.*)$ $1f$2
RewriteRule ^([^G]*)G(.*)$ $1g$2
RewriteRule ^([^H]*)H(.*)$ $1h$2
RewriteRule ^([^I]*)I(.*)$ $1i$2
RewriteRule ^([^J]*)J(.*)$ $1j$2
RewriteRule ^([^K]*)K(.*)$ $1k$2
RewriteRule ^([^L]*)L(.*)$ $1l$2
RewriteRule ^([^M]*)M(.*)$ $1m$2
RewriteRule ^([^N]*)N(.*)$ $1n$2
RewriteRule ^([^O]*)O(.*)$ $1o$2
RewriteRule ^([^P]*)P(.*)$ $1p$2
RewriteRule ^([^Q]*)Q(.*)$ $1q$2
RewriteRule ^([^R]*)R(.*)$ $1r$2
RewriteRule ^([^S]*)S(.*)$ $1s$2
RewriteRule ^([^T]*)T(.*)$ $1t$2
RewriteRule ^([^U]*)U(.*)$ $1u$2
RewriteRule ^([^V]*)V(.*)$ $1v$2
RewriteRule ^([^W]*)W(.*)$ $1w$2
RewriteRule ^([^X]*)X(.*)$ $1x$2
RewriteRule ^([^Y]*)Y(.*)$ $1y$2
RewriteRule ^([^Z]*)Z(.*)$ $1z$2

RewriteRule .* - [E=changed:yes,N]
RewriteCond %{ENV:changed} ^yes$

RewriteRule (.*) http://example.com/$1 [R=301,L]
This would go through each individual letter in a folder/file request one by one and check if it's capital or not, and then proceed to the next letter. Again this is not as efficient as simply planning out the correct consistent case to use from the beginning. Please let us know if you have any other questions at all. - Jacob