Trailing slashes on directories

I want my site to follow a convention of not using trailing slashes (regardless of file or directory). Is it possible to configure apache in a way that navigating to www.sitename.com/directory does not issue a 301 redirect to www.sitename.com/directory/ and just returns the same content?

JH,

That depends upon your host. I’m not sure what the Apache directive is to NOT add a trailing slash but, if your host is forcing the trailing /, you can’t do anything about it.

Hint: Ask your host.

With mod_rewrite, you CAN remove the trailing / (provided Apache will allow it via httpd.conf) with code like:

RewriteEngine on
RewriteRule ^(.*)/$ $1 [R=301,L]

Regards,

DK

I do have full control over the server so I can add any directives I need.

With your mod_rewrite rule above, wouldn’t this cause an endless loop since apache is forcing redirects for urls with missing trailing slashes?

thanks.

JH,

Yes, if the server is forcing trailing slashes, LOOPY!

Regards,

DK