0

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.
Kevin
  • 133
  • 1
  • 2
  • 14
  • Do you really need to do this at all? It violates the HTTP specification and makes your server a bit unpredictable. It's much better to fix the broken links. – Michael Hampton Feb 21 '19 at 15:25
  • It may be better, however, who is going to pay to have someone fix 900,000+ broken links? When it all worked fine when it was on a windows server? No-one... hence, I ask – Kevin Feb 21 '19 at 19:42
  • Yes, that's one of the few legitimate reasons to use mod_speling. But the case of the broken links still needs to be fixed; it's only a workaround so that you don't have 404s when you move away from Windows. The internal links can be fixed with automation, so it doesn't matter much how many there are. It's the external links that should keep you awake at night. – Michael Hampton Feb 21 '19 at 20:28
  • https://webmasters.stackexchange.com/a/44059/17007 – Michael Hampton Feb 22 '19 at 02:27
  • no dice. pass through does not seem to pass through – Kevin Feb 22 '19 at 13:21
  • i think a bigger part of this is how ServerPilot is setup. Requests come in like this: Web Browser -> Nginx -> Apache -> PHP-FPM so, it hits nginx first and foremost.... which was why I had the nginx tag on this question that was editted off of it... – Kevin Feb 22 '19 at 14:30
  • 2
    @MichaelHampton The other reason that systems administrators may be forced into doing all this is when the web developers are coming from a Windows background and they expect the violations of the HTTP specs to be the norm. – doneal24 Feb 22 '19 at 15:39
  • Dang Windows! lol I am cannot disagree with him about that, because I do agree... however, it is true in both aspects... migrating a site from a Windows server to Linux, plus the aspect that there could be way more redirects, or renaming than is worth tackling – Kevin Feb 22 '19 at 15:41
  • p.s. I figured it out with a `DirectoryMatch` inside the apps vhost config, unfortunately, I cant post the answer for another 23 hours it looks like... – Kevin Feb 22 '19 at 15:42

1 Answers1

0

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

Kevin
  • 133
  • 1
  • 2
  • 14