The following .htaccess rule un-matches string admin and adds a trailing slash(/) to that URL if admin is not found in the URL
RewriteRule ^((?!admin).)*((?!\/).)$ /$1/ [L,R]
But it has an error, and it is
http://www.domain.com/index
should result to : http://www.domain.com/index/
But currently it is resulting: http://www.domain.com/inde/
Please find a solution to correct it. Thanks Very much .
Your expression captured the last character in a group.
This will solve the issue:
RewriteRule ^(?!.*admin)(.*?)\/?$ /$1/ [L,R]
Check out the explained demo here: http://regex101.com/r/kL6pV1
Note: this will invalidate any URL that contains admin
, not necessarily starting with admin
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.