从实际目录中删除尾部斜杠 [英] Remove trailing slash from real directories

查看:97
本文介绍了从实际目录中删除尾部斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好吗?

在该线程中上一章的重定向和重写规则之后,重定向到除/ amp / Urls 以外的默认语言,我们的SEO代理建议我们更改URL站点。 com / fr,site.com / be到site.fr和site.be

after the previous episode of redirecting and rewriting rules in this thread: redirect to default language except for /amp/ Urls, our SEO agency recommended us to change the URLs site.com/fr, site.com/be to site.fr and site.be

我已经将旧网址的301重定向设置如下:

I already set the 301 redirections for old URLs as follow:

RewriteRule ^[a-z]{2}$ / [R=301,L]
RewriteRule ^[a-z]{2}/(.*)$ /$1 [R=301,L]

我知道这可以通过一条规则来实现但没有成功:/

I know this can be achieved in one rule but didn't manage to make it work :/

因为我现在删除了language文件夹,所以删除尾部的斜杠实际上并不能很好地工作。 site.com/test添加斜杠,因为文件夹 test存在并且是真实文件夹。我尝试关闭DirectorySlash,但返回了禁止的403错误。
请问如何解决这个问题?

since I now removed the language folder, removing the trailing slash does't really work well. site.com/test adds the slash because the folder "test" exists and is a real folder. I tried DirectorySlash Off but it returns a forbidden 403 error. please any idea how to solve this?

非常感谢

推荐答案

下面我的评论:

将显示的两个规则合并为一个:

Combining those 2 shown rules into one:

RewriteRule ^[a-z]{2}(?:/(.*))?$ /$1 [R=301,L,NE]

这篇关于从实际目录中删除尾部斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆