删除结尾的斜杠 [英] Remove trailing slashes

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

问题描述

我想用网页来工作,没有结尾的斜杠。所以,现在我想我的网址与结尾的斜线(使用的.htaccess)重定向到相同的URL没有斜线。

I'd like to work with pages without trailing slashes. So now I want my URL's with an trailing slash to redirect (using .htaccess) to the same URL without the trailing slash.

我有两个.htaccess文件:

I got two .htaccess files:

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteRule (.*)  public/$1
</IfModule>

和一个在我公用文件夹:

And one in my public folder:

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>

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

I tried adding the following rule to the .htaccess file in the public folder:

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

但后来: example.com/public/page/view/2 /

But then: example.com/public/page/view/2/

重定向到: example.com/D:/webserver / 公开/页/视图/ 2

Redirects to: example.com/D:/webserver/public/page/view/2

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

Which is obviously not what I want...

推荐答案

为什么你有几个.htaccess文件?到哪里都是一个人的重定向到公共/ $ 1存储在哪里?你很可能会面临着复杂的事情对你压倒一切的重写规则指令。

Why do you have several .htaccess files? Where are the one's redirecting to public/$1 stored? You may very well be facing overriding RewriteRule directives that complicate things for you.

不知道你的设置是非常很难说你应该如何使用重写 - 你可以指定哪些东西实际上是寻找像

Without knowing your setup it's fairly hard to say how you should be using rewrites - can you specify what things are ACTUALLY looking like?

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

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