从实际目录中删除尾部斜杠

编程入门 行业动态 更新时间:2024-10-14 16:27:31
本文介绍了从实际目录中删除尾部斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你好吗?

在该线程中上一章的重定向和重写规则之后,重定向到除/ amp / Urls 以外的默认语言,我们的SEO代理建议我们更改URL站点。 com / fr,site / 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/fr, site/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/test添加斜杠,因为文件夹 test存在并且是真实文件夹。我尝试关闭DirectorySlash,但返回了禁止的403错误。 请问如何解决这个问题?

since I now removed the language folder, removing the trailing slash does't really work well. site/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]

更多推荐

从实际目录中删除尾部斜杠

本文发布于:2023-11-01 13:16:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549423.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:斜杠   尾部   目录中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!