小编Bri*_*eña的帖子

如果在最后一个斜杠之前没有扩展名,.htaccess 添加斜杠

我在这里有一个代码,它通过在末尾添加斜杠来重写 url。健康)状况:

  1. 无文件扩展名
  2. 结尾没有斜线

RewriteEngine On
RewriteCond %{REQUEST_URI} !\..*$
RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/Brian/$1$2/ [L,R=301]
Run Code Online (Sandbox Code Playgroud)

如果网址是:

http://localhost:8080/Brian/test123 -> http://localhost:8080/Brian/test123/ - CORRECT
http://localhost:8080/Brian/test123. -> http://localhost:8080/Brian/test123. - CORRECT
http://localhost:8080/Brian/test123.awd -> http://localhost:8080/Brian/test123.awd - CORRECT

http://localhost:8080/Brian/test123.awd/a -> http://localhost:8080/Brian/test123.awd/a - THIS IS MY PROBLEM
Run Code Online (Sandbox Code Playgroud)

我想做出这样的结果。

http://localhost:8080/Brian/test123.awd/a/
Run Code Online (Sandbox Code Playgroud)

请帮忙。谢谢!

regex apache .htaccess mod-rewrite

2
推荐指数
1
解决办法
59
查看次数

标签 统计

.htaccess ×1

apache ×1

mod-rewrite ×1

regex ×1