我想配置 Case InSenSitive Web 服务器

I want to configure a Case InSenSitive web server

注意:我读到的很多帖子都在谈论 httpd,有人告诉我,这误导了我, 现代 Apache 不使用 httpd.conf 文件,而是使用它自己的 apache2.conf

我已经在带有 debian

的 vps 上安装了 apache

我已经发出了以下命令

sudo a2enmod speling
sudo service apache2 restart
cd /etc/apache2/sites-available
sudo a2ensite 000-default
sudo service apache2 restart

如果我尝试在我的 /etc/apache2/apache2.conf 中将 AllowOverride 从 None 更改为全部

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

我在浏览器中收到以下错误? http://www.mumti.com/indeX.HtmL

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.
Apache/2.4.25 (Debian) Server at www.mumti.com Port 80

这里是 /etc/apache2/sites-available/000-default.conf

的副本
<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName www.mumti.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf


</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

这是我的/var/www/.htaccess的副本,我完全不知道它是否生效,你怎么知道?

#
# 20200311
# https://www.a2hosting.com/kb/developer-corner/apache-web-server/using-the-mod-speling-apache-module
# AllowOverride All

#<Directory />
#   Options Indexes FollowSymLinks
#   AllowOverride All
#   Require all granted
#</Directory>


# 
# 20200310
RewriteEngine on
CheckSpelling on

# https://www.a2hosting.com/kb/developer-corner/apache-web-server/using-the-mod-speling-apache-module
<IfModule mod_speling.c>
    CheckCaseOnly on
    CheckSpelling on
</IfModule>

有人说根本不要使用 .htaccess,我同意。请告诉我如何单独通过 /etc/apache2/sites-available/000-default.conf/etc/apache2/apache2.conf 来实现问题的标题。

我希望能够以任何拼写请求域的 URL,无论它是文件还是目录

感谢所有贡献者和这个伟大的网站。

更新:有关error.log的更多信息请求,好的,我找到了这个文件所在的位置。这是 /var/log/apache/error.log

的尾巴
[Wed Mar 11 18:59:50.815205 2020] [mpm_event:notice] [pid 3281:tid 140482295300160] AH00489: Apache/2.4.25 (Debian) configured -- resuming normal operations
[Wed Mar 11 18:59:50.815277 2020] [core:notice] [pid 3281:tid 140482295300160] AH00094: Command line: '/usr/sbin/apache2'
[Wed Mar 11 18:59:56.596612 2020] [core:alert] [pid 3283:tid 140482088769280] [client 24.20.17.209:24867] /var/www/.htaccess: <Directory not allowed here
[Wed Mar 11 18:59:59.797563 2020] [core:alert] [pid 3283:tid 140482097161984] [client 24.20.17.209:24872] /var/www/.htaccess: <Directory not allowed here
[Wed Mar 11 19:00:02.115843 2020] [core:alert] [pid 3283:tid 140482080376576] [client 24.20.17.209:24877] /var/www/.htaccess: <Directory not allowed here
[Wed Mar 11 19:02:09.976967 2020] [core:alert] [pid 3282:tid 140482122340096] [client 24.20.17.209:25087] /var/www/.htaccess: <Directory not allowed here
[Wed Mar 11 19:02:11.213632 2020] [core:alert] [pid 3282:tid 140482113947392] [client 24.20.17.209:25090] /var/www/.htaccess: <Directory not allowed here
[Wed Mar 11 19:02:26.878673 2020] [core:alert] [pid 3282:tid 140482105554688] [client 24.20.17.209:25119] /var/www/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
[Wed Mar 11 19:02:28.125043 2020] [core:alert] [pid 3282:tid 140482097161984] [client 24.20.17.209:25122] /var/www/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
[Wed Mar 11 19:02:29.623182 2020] [core:alert] [pid 3282:tid 140482088769280] [client 24.20.17.209:25126] /var/www/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
[Wed Mar 11 19:02:32.544649 2020] [mpm_event:notice] [pid 3281:tid 140482295300160] AH00491: caught SIGTERM, shutting down
[Wed Mar 11 19:02:32.636398 2020] [mpm_event:notice] [pid 3361:tid 139631042101312] AH00489: Apache/2.4.25 (Debian) configured -- resuming normal operations
[Wed Mar 11 19:02:32.636474 2020] [core:notice] [pid 3361:tid 139631042101312] AH00094: Command line: '/usr/sbin/apache2'
[Wed Mar 11 19:02:36.250353 2020] [core:alert] [pid 3363:tid 139630838007552] [client 24.20.17.209:25137] /var/www/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
[Wed Mar 11 19:02:37.400118 2020] [core:alert] [pid 3363:tid 139630829614848] [client 24.20.17.209:25141] /var/www/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
[Wed Mar 11 19:02:38.932964 2020] [core:alert] [pid 3363:tid 139630821222144] [client 24.20.17.209:25144] /var/www/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
[Wed Mar 11 19:04:54.443494 2020] [mpm_event:notice] [pid 3361:tid 139631042101312] AH00491: caught SIGTERM, shutting down

请记住,您可以指示我配置实现目标所需的任何最低设置。除了配置文件上面的小调整尝试外,其他晚上的 apache 默认安装非常接近。谢谢。

另外,为什么我会收到此回复?

admin@VRR:~$ sudo service apache2 restart
: invalid option-
history: usage: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
admin@VRR:~$

我在建议的答案中应用了@MrWite 000-default.conf 的建议模板,但上面的 sudo service apache2 restart 投诉仍然存在?无效选项?? 这里是最近的error.log(我最近擦了)

[Wed Mar 11 21:47:47.515090 2020] [mpm_event:notice] [pid 3621:tid 140717672165440] AH00489: Apache/2.4.25 (Debian) configured -- resuming normal operations
[Wed Mar 11 21:47:47.515169 2020] [core:notice] [pid 3621:tid 140717672165440] AH00094: Command line: '/usr/sbin/apache2'
[Wed Mar 11 21:59:14.795332 2020] [mpm_event:notice] [pid 3621:tid 140717672165440] AH00491: caught SIGTERM, shutting down
[Wed Mar 11 21:59:14.895378 2020] [mpm_event:notice] [pid 3716:tid 140701491482688] AH00489: Apache/2.4.25 (Debian) configured -- resuming normal operations
[Wed Mar 11 21:59:14.895455 2020] [core:notice] [pid 3716:tid 140701491482688] AH00094: Command line: '/usr/sbin/apache2'

我发现 invalid option 有问题,这是我上传我的 .bash_profile 的结果,用于 windows 编程,我想不是所有的 bash 命令是一样的去图...

我希望有一个像这里看到的那样的 system/command 提示 https://youtu.be/7QF0toTZLbw?t=164

注意:它不仅是 URL,还有引用的文件。接受的答案即使在 HTML 中引用图像文件名也有效,比如 <img src="sensitive.jpg"/> 而实际文件名是 case-mangled 就像 SenSitive.JpG 它真的有效谢谢你 APACHE !!!

如果您有权访问服务器配置,那么就没有必要 .htaccess(除非这有助于分发)。

请尝试以下方法:

<VirtualHost *:80>
    # Assuming you want to access the domain apex as well?
    ServerName example.com
    ServerAlias www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    <Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted

        # Case-Insensitive
        CheckSpelling on
        CheckCaseOnly on
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

并删除 .htaccess 文件。

请注意 DocumentRoot(站点的根目录)是 /var/www/html。您需要在相应的 <Directory> 容器中授予对该目录的访问权限。通常是 .htaccess 文件所在的目录(如果启用)。