- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用的是 Apache 2.4,并设置了两个虚拟目录。一个需要 SSL,另一个重定向到它。
如果用户尝试访问 https://www.derp.com/derp
如果/derp 不存在,它们会正确地得到 404。但是当用户访问 http://www.derp.com/derp
时, Apache 错误地将用户重定向到 https://www.derp.comderp
,删除路径和域名之间的斜线。
我不知道是什么原因造成的。
以下是我的虚拟主机的设置。
<VirtualHost *:443>
ServerAdmin derp@derp.com
ServerName www.derp.com
ServerAlias derp.com
DocumentRoot "C:\Users\derp\Documents\Web Projects\derp"
SSLEngine on
SSLCertificateFile "C:\Apache24\certs\cert.cer"
SSLCertificateKeyFile "C:\Apache24\certs\key.key"
</VirtualHost>
<VirtualHost *:80>
ServerAdmin derp@derp.com
ServerName www.derp.com
ServerAlias derp.com
Redirect permanent / https://www.derp.com/
</VirtualHost>
<Directory "C:\Users\derp\Documents\Web Projects\derp">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
SSLRequireSSL
</Directory>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
http://www.derp.com
开始时,它会正确重定向至
https://www.derp.com
.仅当您指定路径并尝试使用 https 时,它才会删除域和路径之间的斜线。
Redirect permanent / https://www.derp.com/
Try
RedirectMatch permanent /(.*) https://www.derp.com/$1
or
RedirectMatch permanent (.*) https://www.derp.com/$1
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
最佳答案
我得到了它。
问题根本不在于重写,而是 SSLRequireSSL导致问题的我的目录定义下的指令。
我只是删除了这个指令,刷新了所有浏览器中的缓存,然后该站点继续正常工作。这是通过消除过程发现的。
文档说明:
This directive forbids access unless HTTP over SSL (i.e. HTTPS) is enabled for the current connection. This is very handy inside the SSL-enabled virtual host or directories for defending against configuration errors that expose stuff that should be protected. When this directive is present all requests are denied which are not using SSL.
Redirect
规则。重写规则,例如
this answer on Server Fault 中的规则根据您的用例,可能是更好的选择:
RewriteEngine On
RewriteCond %{SERVER_PORT} !443
RewriteRule ^(/(.*))?$ https://%{HTTP_HOST}/$1 [R=301,L]
关于apache - 为什么 Apache 永久重定向会删除域和路径之间的斜线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20042434/
我有这个代码: set_value(X,Value,[X/_|T],[X/Value|T]). set_value(X,Value,[Y/V|T],[Y/V|NewT):- X\=Y,set_valu
如何绘制非正交线? 如果我们有一条正交线,那就很简单了: 考虑 X1 = 100,Y1 = 80; X2=100,Y2=185; 所以对于这条线我们有类似的东西。 for(nRow = Y1; nRo
如何使用 CSS 实现斜斜线 (/)?它应该具有响应能力并且还应该支持 IE 8? 最佳答案 你可以使用一个元素,用伪元素和边框隐藏不需要的部分(IE8支持): div{ position:r
我正在通过 PayPal SDK 为 REST API 创建支付。一切似乎都正常,重定向到 paypal,付款本身。但是当我从 paypal 返回我的商店时,returnUrl 的末尾添加了一个“/”
我的值为: 1/2 3/4/5 2/3/6 我想求值2所以结果一定是 1/2 2/3/6 我不想使用 LIKE 运算符。有没有办法在 FIND_IN_SET 函数中设置分隔符? 最佳答案 您可以使用l
我已经设置了我的第一个 REST API,并且我是使用 Taffy 框架的新手。 我有一个使用 ColdFusion 10、IIS 并使用 ColdBox 的站点。我在目录中设置了一个 hello w
当我在 website.com/seo.php 上输入 htaccess 代码时,它重定向到 website.com/seo,但我希望它执行 website.com/seo/ 我的 htaccess
这个问题在这里已经有了答案: Bare asterisk in function arguments? (6 个回答) What does the slash mean in help() outpu
我团队中的一个人在处理他从我们的 SVN 获得的项目时遇到了问题。当他尝试运行文件时出现错误: java.lang.NoClassDefFoundError: misc\test (wrong nam
我是 Laravel 的新手,它似乎是一个很棒的框架,但我对路由有疑问。我想将所有获取请求路由到一个名为 PageController@view 的 Controller 操作,但是当前缀是 admi
我想重定向域中的所有 url: http://exampledomain.com 到特定地址上的新域,该地址仅在地址末尾没有尾部斜杠的情况下有效 http://www.newdomain.com/12
在本地出现 2 个错误(两种情况下的代码几乎相同): PS C:\Users\jonat\Projects\latex_classifier> cargo test --release Fin
我正在从一个存在许多不一致的旧应用程序重建一个 Web 应用程序。我必须将所有数据从旧数据库迁移到我们的新结构。 在旧数据库中,日期以 VARCHAR 形式存储在 MySQL 数据库中。 我们位于英国
这实际上只是一个语法问题。 我有一个 PHP 脚本,可以解析我的 WordPress 提要并返回最新的帖子。我还希望我的脚本能够解析评论数量,但是用于评论数量的 WordPress 提要 XML 对象
假设我想要一个单例 里面的东西将其文本/内容分成三列,高度尽可能相等。如何做到这一点? 最佳答案 这是 CSS3 column layout .目前,它通过 vendor 标签得到支持。样本可以在 t
我正在尝试为输入 mm/yy 字段添加功能,这样当用户输入 2 位数字时,会自动添加斜线“/”。 这是我的文本输入 最佳答案 我刚刚在我的应用程序中做了类似的事情,在电话号码中添加了一个“-”:)这
我是一名优秀的程序员,十分优秀!