这是我的。htaccess
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
这两行就是问题所在
RewriteCond %{HTTPS} != on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
…
RewriteRule ^/?$ index.php
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^.*$ index.php
</IfModule>
有没有人知道为什么这是一个内部服务器错误,以及如何修复它,我有一个规则,防止用户访问非https版本,另一个做一些重写url和重定向。我使用一个控制器来处理所有的网页
试试这个。主要的变化是你的https
检测以及使用REQUEST_FILENAME
代替SCRIPT_FILENAME
:
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/?(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
RewriteRule ^/?$ index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php
</IfModule>
也是一个很好的调试技术,这样的东西是使用curl -I
从命令行,如果你是在Unix/Linux或Mac OS X.这将返回头信息,包括重定向&这样的。例如,以下是Google在http://google.com/
上的curl -I
输出:
curl -I http://google.com/
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Wed, 18 Jun 2014 23:20:00 GMT
Expires: Fri, 18 Jul 2014 23:20:00 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Alternate-Protocol: 80:quic
注意HTTP/1.1 301 Moved Permanently
和Location: http://www.google.com/
行。这告诉你谷歌的服务器被设置为将google.com
请求重定向到www.google.com
。与在浏览器中加载URL相比,在你自己的本地规则中使用它是一种很好的调试方式。处理缓存内容问题。
EDIT:既然在你的评论中你解释了index.php
是如何进行的,尝试使用这个稍微修改过的默认WordPress .htaccess
版本:
<IfModule mod_rewrite.c>
RewriteEngine On
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/?(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
RewriteBase /
RewriteRule ^index'.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>