删除尾部斜杠

Eri*_*rik 5 apache .htaccess mod-rewrite

我想使用没有尾随斜杠的页面.所以现在我希望我的URL带有一个尾部斜杠,将(使用.htaccess)重定向到没有尾部斜杠的同一个URL.

我有两个.htaccess文件:

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteRule (.*)  public/$1
</IfModule>
Run Code Online (Sandbox Code Playgroud)

在我的公共文件夹中有一个:

DirectoryIndex index.html index.php
Options -Indexes

<IfModule mod_rewrite.c>
    RewriteEngine On        
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f         
    RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)

我尝试将以下规则添加到公用文件夹中的.htaccess文件中:

RewriteRule (.*)/$ $1 [R,L]
Run Code Online (Sandbox Code Playgroud)

但是:example.com/public/page/view/2/

重定向到:example.com/**D:/webserver/**public/page/view/2

这显然不是我想要的......

Fak*_*e51 2

为什么有多个 .htaccess 文件?重定向到 public/$1 的内容存储在哪里?您很可能会面临压倒性的 RewriteRule 指令,这会让您的事情变得复杂。

在不知道你的设置的情况下,很难说你应该如何使用重写 - 你能指定事情实际上是什么样子吗?