2 Replies - 7188 Views - Last Post: 20 April 2012 - 07:55 PM

#1 sak904  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 72
  • Joined: 03-September 09

Lowercase .htaccess problem

Posted 20 April 2012 - 10:55 AM

Hi there!

I am working on a site. I have all the filenames lowercase, and I want it to not yield a 404 if someone types WHATEVER.php instead of whatever.php. I have tried this in my .htaccess

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]
	
IndexIgnore *


with this in my httpd.conf

RewriteMap  lc int:tolower


The problem is, when I do the URL with upper case letters in it, instead of sending me to the correct page (say, http://www.example.com/example.php), it sends me to the root of the directory my site is hosted on, with the domain in front (say, http://www.example.c...orum/example/). The code for forcing the "www." doesn't seem to be interfering at all (that part works, actually).

What am I doing wrong?

This post has been edited by sak904: 20 April 2012 - 10:58 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Lowercase .htaccess problem

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3717
  • View blog
  • Posts: 5,981
  • Joined: 08-June 10

Re: Lowercase .htaccess problem

Posted 20 April 2012 - 12:47 PM

I seem to recall reading about a bug that caused some inconsistent behavior in mod_rewrite when it tried to guess whether or not to use a file-system path over an URL path, and adding a / in front of the substitution string was a suggested workaround for that.

Also, there was a thread posted here a few days ago about a similar problem. The OP in that thread reported that the RewriteBase directive fixed that issue.
Was This Post Helpful? 0
  • +
  • -

#3 sak904  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 72
  • Joined: 03-September 09

Re: Lowercase .htaccess problem

Posted 20 April 2012 - 07:55 PM

I tried that, but if I do that, it just sends me to the root of the folder. If I went to http://www.example.com/EXAMPLE.php, it would send me to http://www.example.com
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1