【问题标题】:URL trailing slash gets removedURL 尾部斜杠被删除
【发布时间】:2017-05-03 16:46:16
【问题描述】:

我最近发现了一个错误,当我转到 example.com/phpmyadminexample.com/index 时,尾部的斜杠会被删除,所以它会调用 example.comphpadminexample.comindex。斜线之后的所有内容都会发生这种情况。但是如果我有第二个斜杠,比如example.com/index/home,它就可以完美地工作。

我的站点配置中有一个从 http 到 https 的重定向活动,运行 apache2.4。

我的配置:

<VirtualHost *:80>
    ServerName example.net
    Redirect permanent / https://example.net
</VirtualHost>

还有我的 .htaccess:

<IfModule mod_rewrite.c>
  RewriteEngine On
  # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
  #  slashes.
  # If your page resides at
  #  http://www.example.com/mypage/test1
  # then use
  # RewriteBase /mypage/test1/
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond $1 !^(phpmyadmin|index\.php|images|robots\.txt)
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  # If we don't have mod_rewrite installed, all 404's
  # can be sent to index.php, and everything works as normal.
  # Submitted by: ElliotHaughin

  ErrorDocument 404 /index.php
</IfModule>

我环顾四周,但没有找到答案。也许我的配置有问题,有人可以帮助我。

【问题讨论】:

  • 请不要通过回滚我们的改进来破坏您的帖子。
  • 好吧,对不起,我是整个网站的新手,并没有完全看到你对它做了什么,我以为你删除了一些文本,但我看到你把它改成了代码.谢谢

标签: .htaccess apache2.4 trailing-slash


【解决方案1】:

考虑到由于 RewriteCond,这个 RewriteRule 甚至没有为 /phpmyadmin 执行,并且 RewritRule 没有重定向,问题是你将所有未知资源发送到的 index.php 中的一个错误。

或者,您没有向我们展示实际配置。

【讨论】:

    【解决方案2】:

    我当时很笨,只需要清除缓存即可使其正常工作。我不知道究竟是什么不起作用,但我在发布这篇文章之前所做的更改确实奏效了,只是缓存中仍然有错误的版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-19
      • 2016-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-19
      相关资源
      最近更新 更多