问题
I have searched through the related mod_rewrite qustions but I can't anything specific enough so I'll post:
Heres my rule that adds a trailing slash:
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
Only I want to exclude one specific directory eg. /mydirectoryname/ and not add the trailing slash to anything that starts with that. Reason being its breaking some of my ajax calls.
回答1:
Add another RewriteCond:
RewriteCond %{REQUEST_URI} !/mydicrectoryname)/
回答2:
You can descibe that with just one condition:
RewriteCond $0 !^mydirectoryname(/|$)
RewriteRule ^[^\.]+[^/]$ /$0/ [R=301,L]
来源:https://stackoverflow.com/questions/1859536/mod-rewrite-trailing-slash-with-rewritecond