问题标签 [trailing-slash]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1206 浏览

redirect - Pretty-Faces 重定向循环

嗨,我在 tomcat 7 中使用漂亮的面孔 3.3.3

和这个配置

我希望将“browse”之后不带斜杠的请求重定向到browse/(带有斜杠)。背景:如果缺少尾部斜杠,我的相对输出链接不会作为子目录处理,而是作为当前目录中的文件处理。

当我现在要求

我的浏览器进入重定向循环

编辑:

浏览是否有可能是保留关键字?当我用松鼠替换它时,一切都按预期工作:

0 投票
2 回答
718 浏览

.htaccess - 删除 WP 多站点 .htaccess 文件中的尾部斜杠

我创建了一个 .htaccess 文件,其中包含一个站点的重定向,该站点是大型 WordPress 多站点安装的一部分。

.htaccess 内容以此开头(这是必要的,因为同一个 .httacess 文件必须用于多个站点:

然后包含一系列重写,如下所示:

如果我访问mydomain.com/about-my-site,我会正确重定向到mydomain.com/about 但是,如果我访问mydomain.com/about-my-site/(请注意尾部斜杠),我会收到“找不到页面”错误。

0 投票
2 回答
1013 浏览

.htaccess - 新的 htaccess 文件 - 301 重定向和尾部斜杠

我是新来的,我真的需要帮助我正在使用 opencart 版本 1.5.5.1 创建一个新站点,并且我尝试创建自己的 htaccess 文件,但它并没有做我想做的事情。我已经尝试了这个站点和我的主机 sd 中的很多代码,opencart 不是为此而构建的,我不相信。但他们可能是对的,因为它对我不起作用。我安装了一个很好的 seo 模块 SEO Pack Pro,但我认为它不会阻止 htaccess 文件中的更改。

主要问题是使用 301 重定向消除 url 的重复,并获得 www 的标头代码 200 和非 www 的 301 。我很确定它应该是这样的

所以我需要从头开始制作一个新的htaccess文件:

因此,再次将所有非 www url 重定向到 www url,而不仅仅是带有 301 重定向的主页,我想确保所有 www url 后面都有一个斜杠。非 www url 导致重定向后我不需要斜杠吗?还需要将主页从 index.php & index.htm、index.html 重定向到http://www.example.com/

在每个目录和子目录之后还有一个斜杠,我认为我的网站下降了 3 级子目录,现在我不在乎文件名后面是否有斜杠并删除文件扩展名或后面没有斜杠文件名 - 我已经阅读了两边的参数,我认为文件名有一个斜杠并不重要。很抱歉这里的书,如果有人能帮我解决这个问题吗?谢谢,妮可

0 投票
2 回答
1508 浏览

ckeditor - CKEditor Removing trailing slash to close tag

Last week i posted a question that CKEditor wasn't maintaining the trailing slash of the
element. This though had a simple solution. Jquery .replace("<br>", "<br />"). This will be done when the Html is read from the Editor.

It's not a solution that will win a price award. but it worked. (The old post has been removed. because it was project related. and not interesting for other people)

Now the following problem <img> needs to be generated as <img />. The problem stays that the Ckeditor isn't keeping the trailing slash for self closing elements.

Someone told me on the other topic(That's deleted), that possibly we are changing settings of the HTMLWriter plugin. What should be causing the problem. I know the code we are using very good and i am sure that we didn't configure any settings of the html writer.

Besides that we only added custom plugins to the Ckeditor. And we had to shutdown the ACF because it was creating to much problems.

Sadly i can't share any code because it's code of the client.

But does anyone know a simple solution to put the trailing slash? Or if you have had the same problem, and have a solution feel free to anwser.

0 投票
1 回答
334 浏览

.htaccess - .htaccess URL 重定向,干净的 url,斜杠,强制 www

因此,我将我的一个域(我们将其称为 domain.com)重定向到我的一个子目录(我们将其称为文件),并且我正在尝试实现将减少 index?page= 的链接,强制www,并且所有页面都有尾部斜杠。

目前我有

domain.com/index?page=about 或 domain.com/splash

我想要 www.domain.com/about/ 或 www.domain.com/splash/

这是我到目前为止所拥有的:

如果您看不出来,我对Apache并不精通,哈哈。

0 投票
1 回答
630 浏览

.htaccess - Cyclic redirection in .htaccess

I have the following .htaccess file:

The .htaccess file should do the following (for SEO):

  1. Conversion to no-www (http://www.site.com should become http://site.com)
  2. All URIs with trailing slashes should convert to no-trailing-slash: http://site.com/me/ should be redirected http://site.com/me
  3. All URIs with index.php/index.html should convert to just nothing: http://site.com/admin/index.php or http://site.com/admin/ should be eventually displayed as http://site.com

However the current version of .htaccess results in a cyclic redirection when trying to access (http://site.com/admin). The real document that should be fetched by browser is http://site.com/admin/index.php.

Can anyone please help me with this issue?

0 投票
1 回答
19735 浏览

redirect - 仅当目录不存在时,如何从 nginx 中的 URL 中删除尾部斜杠?

我正在使用 PHP-FastCGI 在 nginx 1.4.1 上运行服务器。目前我已经设置了它,以便它从我的 URL 中删除尾部斜杠并发出 301 重定向。但是,当我访问存在的目录时,我被迫进入重定向循环。我当前的文档根目录如下所示:

目前我无法访问 example.com/webgrind 或任何其他目录。我的访问日志反复读取类似于:

这是我的 nginx.conf 中的服务器块:

我知道这rewrite ^/(.*)/$ /$1 permanent;是违规行。如果我删除它并访问 example.com/webgrind,则会发出 301 让我重定向到 example.com/webgrind/,因为它是一个目录。但是,我的应用程序现在将接受尾随和非尾随斜杠(即 example.com/users/ 和 example.com/users),这不是我想要的。

如下将'if'指令包裹在我的重写周围仍然会为我的目录创建一个重定向循环(显然,如果是邪恶的,但在这种情况下,重写指令被认为是安全的):

(我知道访问 webgrind/index.php 可以解决我的问题,但是当我的生产目录被实时推送时,我想避免代价高昂且不专业的重定向循环。)

那么我怎样才能有条件地只为不存在的资源(我的 Web 应用程序路径)去除尾部斜杠?

更新:我的(未更改的)fastcgi_params 配置:

0 投票
1 回答
264 浏览

.htaccess - htaccess:如何删除文件扩展,添加斜杠,并可能保留样式?

我试图用 htaccess 屏蔽 html 和 shtml 文件的文件扩展名。我对htaccess了解不多,我设法做的是删除扩展名,将尾部斜杠添加到shtml页面,然后停在那里。我也想在 html 文件中添加斜杠,但我对该主题的研究让我无处可去。看起来我要么生成一个带有两个斜杠的 url,要么生成一个带有假目录、斜杠和文件扩展名的 url,或者由于某种奇怪的原因而丢失了页面的样式。

我基本上已经尝试了我所知道的一切。这是我所拥有的:

有没有办法添加斜杠并保持页面的样式?我确定有一个,但我似乎无法找到它...在此先感谢

0 投票
1 回答
295 浏览

asp.net-mvc-4 - Iis7 设置导致尾随反斜杠

当我将相同的 MVC4 asp.net 网站部署到两个不同的 IIS7 服务器时遇到问题。

在一个框中,当我为我的网站点击“主页”按钮时,我得到一个尾随反斜杠,而在另一个我没有。问题是,在不附加尾部反斜杠的框中,jquery 自动完成不起作用。当我添加反斜杠时,它确实如此。所以这是我想要的默认行为。即带有反斜杠。

两个盒子都有相同的网站,具有相同的 web.config,两个 iis 服务器都没有安装 url 重写,所以如果我不需要,我不想走这条路。一个盒子上的 iis 设置必须与另一个盒子不同,但我已经经历了每一个,但没有发现任何区别。有谁知道是什么导致了这种情况或指出我正确的方向?

任何帮助,将不胜感激。

我知道在同一区域还有其他问题,但没有人回答我的问题。

更新:

我注意到有关导致反斜杠的 URL 中的周围的 stackoverflow 的一些问题,并且我还意识到添加尾随反斜杠的服务器在其地址中有一个点/句点。所以这看起来可能会导致我的问题。

我想正确的做法是让它在两个盒子上都没有斜杠。所以现在我的问题是为什么我的 jquery 自动完成不能在没有尾随反斜杠的地址上工作。

请参阅问题重新:网址中的点

例如:

0 投票
1 回答
792 浏览

trailing-slash - IIS 7.5:删除尾部斜杠不起作用

我们有 ASP.NET 应用程序并在 web.config 中设置:

但是,尾部斜线仍然存在。

另外,我尝试使用 Global.asax.cs 文件中的代码:

但是,它也不起作用。

具体来说,“elki”是项目中的子文件夹,它有自己的 web.config 文件,如下所示:

如何使其工作,即删除斜杠?