在RH7下使用Apache可能是一个不区分大小写的URL?

更新于2017年8月23日,请参见下文

在Apache访问声明的目录之前,我想让RedHat 7中的URL不区分大小写。

我试着用mod_rewrite和mod_speling。 他们中没有人工作。 我知道Linux是一个区分大小写的操作系统。

我的目标是让我的API案例的URL不知情。 我已经宣布了一个httpd的最低设置,只是它甚至运行。 我还为特定的任务或设置添加了所需的模块。

我该怎么办? 或者更好:请向我解释怎么可能或为什么不起作用?


在23-08-2017更新

我得到了一个403(禁止)的错误消息,我没有权限访问服务器上的API / v1 /当我打电话给我这样的API:

https://servername/API/v1 

以下是Apache(httpd)设置的摘录:

 ## 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#[AZ]#"> RewriteCond %{REQUEST_URI} [AZ] 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> 

只需使所有url小写,句点。 任何大写字母都会通过redirect到相应的小写字母转换为小写字母。 这使得它不区分大小写,不允许使用任何大写,并透明地将url更改为全部小写。

Apache .htaccess代码:

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