gpt4 book ai didi

.htaccess - htaccess 永久重定向抛出内部服务器错误

转载 作者:行者123 更新时间:2023-12-02 03:03:39 25 4
gpt4 key购买 nike

mod_rewrite documentation对于 Apache 2.2,RewriteRule [R] 标志状态:

Any valid HTTP response status code may be specified, using the syntax [R=305], with a 302 status code being used by default if none is specified. The status code specified need not necessarily be a redirect (3xx) status code. However, if a status code is outside the redirect range (300-399) then the substitution string is dropped entirely, and rewriting is stopped as if the L were used.

In addition to response status codes, you may also specify redirect status using their symbolic names: temp (default), permanent, or seeother.

但是下面的代码片段似乎只允许“符号名称”:

# Force HTTPS
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off

# this works
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent,NE]

# this doesn't work
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=308,NE]

错误日志显示:

[Tue May 23 23:11:12 2017] [alert] [client 192.168.33.1] /var/www/html/ventus/.htaccess: RewriteRule: invalid HTTP response code '308' for flag 'R'

但是,308 似乎是永久重定向的 HTTP 状态代码:https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308

这是 Apache 中的错误还是我做错了什么?

最佳答案

您的 apache (2.2) 版本不能使用 308。在 apache 2.4.3 中添加了对 308 状态的支持:https://archive.apache.org/dist/httpd/CHANGES_2.4.3

core: Add missing HTTP status codes registered with IANA.

关于.htaccess - htaccess 永久重定向抛出内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44146566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com