Fixing Case Insensitive URLs with mod_speling in Apache

apache-2.4case-insensitivenginxstatic-contentWordpress

I have a ServerPilot server, running on Ubuntu 16.04.3

On it is an app that is a WordPress website, but has other non-wordpress directories. In these directories is what I am concerned about.

I have verified that mod_speling is indeed enabled on the server… however, when I put in the

CheckCaseOnly on
CheckSpelling on

to my apps .htaccess file, the case insensitive URL's still resolve as WordPress 404's instead of actually resolving.

Unfortunately, the site is in test/QA phase so I cannot give the actual URL, however, as an example:

https://www.example.com/university/Smartapp/External/index.html resolves properly, because in the app, that path is exactly that, with the capital S and capital E… however… the URL https://www.example.com/university/smartapp/external/index.html throws the WordPress 404 Page Not Found

What can I do to get this working?

EDIT
So close… I think what is happenning is WordPress is processing first.

So… I implemented the following:

CheckCaseOnly On
CheckSpelling On

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/university/(.*)$ [OR]
    RewriteCond %{REQUEST_URI} ^/events/(.*)$ [OR]
    RewriteCond %{REQUEST_URI} ^/Videos/(.*)$ [OR]
    RewriteCond %{REQUEST_URI} ^/2017-holiday-card/(.*)$ [OR]
    RewriteCond %{REQUEST_URI} ^/Holiday-Card/(.*)$ [OR]
    RewriteRule ^.*$ - [L]
</IfModule>


# BEGIN WordPress
RewriteEngine On

RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
# END WordPress

And ServerPilot's default nginx config for the app is:

location / {
    proxy_pass      $backend_protocol://$backend_host:$backend_port;
}

I thought to do something like:

location ~* ^/university/ {
    proxy_pass      $backend_protocol://$backend_host:$backend_port;
}

but it too does not seem to do anything…

Which, does indeed allow the case insensitive URL's to work… however, it does break WordPress's permalinks, as all inner pages of the wordpress side now 404

ServerPilot processes requests as such: Web Browser -> Nginx -> Apache -> PHP-FPM, please leave the nginx tag on the question since it is relative to it.

Best Answer

Ended up having to forgo .htaccess for this to work

What does the trick is adding:

<DirectoryMatch "(^|/)university($|/)">
    CheckCaseOnly On
    CheckSpelling On
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/university/(.*)$ [OR]
    RewriteRule ^.*$ - [L]
</DirectoryMatch>

to the vhost config for the app