TOA Posted April 13, 2012 Share Posted April 13, 2012 I've just inherited a site structure where the folders are capitalized (ex. www.site.com/Folder/page.php). It's my understanding that it's led to some user complaints about the url's being 'too picky'...ie. case sensitive. Instead of going through an extensive amount of code line by line to change it, I thought I'd create a rewrite rule that maps any incoming lowercase urls to the first letter uppercase equivalent (only if it's between the //'s though -- a directory). I've tried, but failed miserably to create the correct rule, and I've searched 'the engine that shall not be mentioned' but can only find examples of how to map to lowercase files/folders, not the other way around. Can anyone offer some help to a frustrated soul? Quote Link to comment https://forums.phpfreaks.com/topic/260874-help-with-re-writing-urls-mod_rewrite-in-htaccess/ Share on other sites More sharing options...
TOA Posted April 13, 2012 Author Share Posted April 13, 2012 Just a thought: Here's my current .htaccess (stripped of the site name for his protection) Options +FollowSymLinks RewriteEngine On # redirect .net, .org, etc to .com RewriteCond %{HTTP_HOST} !^www\.site\.com RewriteRule (.*) https://www.site.com/$1 [R=301,L] # redirect to ssl RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} # remove php extensions for friendly urls RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^([^/]+)$ $1.php Would just adding the no-case flag to the first one work? Like this? RewriteRule (.*) https://www.site.com/$1 [NC][R=301,L] Quote Link to comment https://forums.phpfreaks.com/topic/260874-help-with-re-writing-urls-mod_rewrite-in-htaccess/#findComment-1337104 Share on other sites More sharing options...
TOA Posted April 13, 2012 Author Share Posted April 13, 2012 I can answer that...nope it didn't. Tried RewriteRule (.*) https://www.site.com/$1 [NC][R=301,L] which caused an internal error and I tried RewriteRule (.*) https://www.site.com/$1 [R=301,L,NC] and that did nothing (that I could tell) Quote Link to comment https://forums.phpfreaks.com/topic/260874-help-with-re-writing-urls-mod_rewrite-in-htaccess/#findComment-1337111 Share on other sites More sharing options...
TOA Posted April 13, 2012 Author Share Posted April 13, 2012 Well, this is what I've come up with so far. RewriteRule ^/[a-z]{1}.*(?=.) [A-Z] I think the pattern is correct, but I'm not that good with them. I'm also not sure that last part is correct ([A-Z]). Will that turn the whole thing to uppercase? Am I on the right track even? Thanks for looking. Quote Link to comment https://forums.phpfreaks.com/topic/260874-help-with-re-writing-urls-mod_rewrite-in-htaccess/#findComment-1337149 Share on other sites More sharing options...
TOA Posted April 13, 2012 Author Share Posted April 13, 2012 HA! Never knew this thread existed! Thanks Mods. Quote Link to comment https://forums.phpfreaks.com/topic/260874-help-with-re-writing-urls-mod_rewrite-in-htaccess/#findComment-1337159 Share on other sites More sharing options...
TOA Posted April 16, 2012 Author Share Posted April 16, 2012 Well, I didn't have any time over the weekend to try anything else, so I'm still looking for help with this if anyone's reading (although I'll probably have a few minutes this morning to try some things). Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/260874-help-with-re-writing-urls-mod_rewrite-in-htaccess/#findComment-1337793 Share on other sites More sharing options...
TOA Posted April 16, 2012 Author Share Posted April 16, 2012 mod_speling worked for me. Quote Link to comment https://forums.phpfreaks.com/topic/260874-help-with-re-writing-urls-mod_rewrite-in-htaccess/#findComment-1337922 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.