apache.htaccessmod-speling

I want to configure a Case InSenSitive web server


NOTE: A lot of the posts I read talk about httpd, and that mislead me, I was told, Modern Apache does not use the httpd.conf file, but instead uses its own apache2.conf

I have installed apache on a vps with debian

I have issued the following commands

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

If I try to change AllowOverride from None to All in my /etc/apache2/apache2.conf specifically this section

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

I get the following error in the browser? 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

Here is a copy of /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

Here is a copy of my /var/www/.htaccess, I don't know if it is taking effect at all, how can you tell?

#
# 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>


# https://stackoverflow.com/questions/17223855/how-would-i-make-apache-case-insensitive-using-htaccess
# 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>

Some say don't use .htaccess at all, I am fine with that. Please show me how to achieve the Question's Title whether thru /etc/apache2/sites-available/000-default.conf or /etc/apache2/apache2.conf alone.

I am want to be able to request a domain's URLs in any spelling whether it be a file or directory

Thank you to all contributors and to this Great Site.

Update: more info requests about error.log, OK I found where this file is located. Here is the tail of /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

Keep in mind you can instruct me to configure whatever minimum settings needed to achieve the goal. Except for the minor tweaks attempts above the config files are very close to the default install of apache the other night. Thanks.

Also why am I getting this response?

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:~$

I am applied @MrWite the suggested template for 000-default.conf in the proposed answer but the sudo service apache2 restart complaint above remains ? invalid option ?? Here is the recent error.log (I recently wiped it).

[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'

I found the issue with invalid option thingy, it's the result of me uploading my .bash_profile used for my mintty on windows programming, I guess not all bash command are the same go figure... enter image description here

I would love to have a system/command prompt like the one seen here https://youtu.be/7QF0toTZLbw?t=164

Note: It's not just URLs but referenced files as well. The accepted answer works even with referenced image filenames inside HTML like <img src="sensitive.jpg"/> while the actual filename is case-mangled like so SenSitive.JpG it really works THANK YOU APACHE !!!

enter image description here


Solution

  • If you have access to the server config then there isn't really any need for .htaccess (unless this helps with distribution).

    Try the following instead:

    <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>
    

    And remove the .htaccess file.

    Note the DocumentRoot (the root directory of your site) is /var/www/html. It is this directory that you need to grant access to in the corresponding <Directory> container. And is ordinarily the directory that the .htaccess file should be located (if enabled).