3

My dev server (Debian 8.5) has DirectorySlash Off in the conf file for a site, and it works - no trailing slash added, and no redirect on requests for an existing directory.

The same directive is in the conf file for the same site on the test server (Ubuntu 16.04) but it has no effect - Apache keeps stubbornly adding the slash and redirecting.

/etc/apache2/sites-available/site1.conf looks like this on both servers:

<VirtualHost *:8080>
    # ...
    ServerAdmin webmaster@localhost
    DocumentRoot /srv/www/site1
    DirectorySlash Off

How can I stop the redirect?

Edit: OOps it was silly, had to clear cache per w3dk (who's helped me 2x today :) Solved.

  • 1
    I've added that as an answer - it might help others. Incidentally, mod_dir (DirectorySlash) is the cause of much confusion as it can "interfere" with mod_rewrite rewrites (triggering redirects when you're not expecting it etc.). – MrWhite Jan 9 '17 at 22:51
2

Make sure your browser cache is cleared. DirectorySlash (mod_dir) adds the slash with a 301 redirect, so these will have been cached (hard) by the browser.

Incidentally, you can check where the slash is being added (browser cache or Apache) by checking the network traffic in the browser.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.