用mod重写删除尾部斜杠?

编程入门 行业动态 更新时间:2024-10-15 10:17:02
本文介绍了用mod重写删除尾部斜杠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这与我以前的问题有关(可以在此处查看).我希望能够从网址中删除斜杠,以便它不会弄乱我网站的某些区域. .htaccess代码在这里:

This relates to my previous question (which can be viewed here). I'd like to be able to remove the trailing slash from the URL so that it doesn't mess up certain areas of my site. The .htaccess code is here:

# -s = File Exists RewriteCond %{REQUEST_FILENAME} -s [OR] # -l = Is a SymLink RewriteCond %{REQUEST_FILENAME} -l [OR] # -d = Is a Directory RewriteCond %{REQUEST_FILENAME} -d # if we match any of the above conditions - serve the file. RewriteRule ^.*$ - [NC,L] # only allows '.' in the "page" portion. RewriteRule ^([^/.]+)/?$ index.php?section=$1 [L] RewriteRule ^([^/.]+)/([^/]+)/?$ index.php?section=$1&page=$2 [L] RewriteRule ^([^/.]+)/([^/]+)/([^/.]+)/?$ index.php?section=$1&page=$2&split=$3 [L]

像以前一样,我对此深有感触,所以有人可以帮忙吗?

As before, I'm out of my depth with this, so can anyone help out?

推荐答案

我假设您正在谈论规则:

I assume you are talking about the rule:

RewriteRule ^.*$ - [NC,L]

因为另一个已经省略了斜杠.

As the other already omit the trailing slash.

尝试以下方法:

RewriteRule ^(.*)/$ $1 [NC,L]

这是我在日志中看到的(缩写):

Here's what I see in the logs (abbreviated):

applying pattern '^(.*)/$' to uri 'host/' rewrite 'host/' -> 'host'

所以我觉得还可以.

更多推荐

用mod重写删除尾部斜杠?

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

发布评论

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

>www.elefans.com

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