简体   繁体   中英

Redirect if using trailing slash in URL. htaccess

How can I make it so when a user uses a trailing slash, for example this link:

website.com/staff/ 

It will redirect to a 404 not found page?

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /$ - [R=404,L]

This will return a 404 not found error for all requests (except directories) if they contain a trailing slash.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM