简体   繁体   English

如果在URL中使用斜杠进行重定向。 htaccess

[英]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? 它将重定向到404未找到页面?

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. 如果所有请求(目录除外)都包含结尾斜杠,则将返回404 not found错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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