0

UPDATED ON 23-08-2017, see section below

I want make URLs under RedHat 7 case-insentitive just before the Apache access to the declared directory.

I tried with mod_rewrite and mod_speling. No one of them works. I know that Linux is a case-sensitive operating system.

My target is to make the URL for my API case-insentitive. I already have declared a minimum setting for httpd, just it even runs. I also added the required modules for a specific task or setting.

What shall I do? Or just even better: Please explain to me how is it possible or why it doesn't work?


UPDATED ON 23-08-2017

I get an error of 403 (Forbidden) with the message that I don't have permission to access /API/v1/ on the server when I call my API like this:

https://servername/API/v1

Here is an extract of the Apache (httpd) setting:

## Rewriting URLs
# The URL rewrite engine switch
RewriteEngine On

# The rewrite map for certain parameters like function()
RewriteMap lowercase int:tolower

# Make all HTTP request to lowercase
<If "%{REQUEST_URI} =~ m#[A-Z]#">
  RewriteCond %{REQUEST_URI} [A-Z]
  RewriteRule (.*) ${lowercase:$1} [L]
</If>

# Make all HTTP request to HTTPS
<If "%{HTTPS} == 'off'">
  RewriteCond %{HTTPS} off [NC]
  RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [R=301,NC,L]
</If>

## Directory Access
# Deny access Serverroot  - Never delete this!
<Directory />
  Require all denied
  AllowOverride None
  Options None
</Directory>

# Allow documents to be served from the DocumentRoot
<Directory "/path/to/my/api/v1">
  Require all granted

  DirectoryIndex index.php
  Options +Indexes +FollowSymLinks
</Directory>

1 Answers1

0

Simply make all of your URLs lowercase, period. Any upper case is converted to lower case by redirecting to the lower case equivalent. This makes it case insensitive by not allowing any uppercase to be used and transparently changing the url to all lowercase.

Apache .htaccess code:

<IfModule mod_rewrite.c>
RewriteMap lc int:tolower
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule ^(.*)$ ${lc:$1} [R=301,L]
</IfModule>