开发者

Apache .htaccess : How to remove slash from directory end?

How to remove slash from directory end?

RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.+)/$
Rewr开发者_开发百科iteRule ^.+/$ %1 [R=301,NE,L]

This rule doesn't work for directories. What is the issue?


I don't think this is going to work.

Say you have a file that in two directories /this and /that. Those two directories are in an Apache root directory /var/www/domain.com

You're looking to turn the directory http://domain.com/that/ to work as http://domain.com/that. But if you think about it, there's already (or could already be) a file that sitting in /var/www/domain.com. So if by your logic Apache allowed rewrites like that, it would only end up requesting the /var/www/domain.com/that file and not the original directory. If /var/www/domain.com/that didn't exist, it would just 404 as you're seeing now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜