在我的MVC应用程序中,我使用.htaccess文件将我的所有请求定向到我的index.php文件。另外,我想强制执行SSL。使用this post,我添加了“#enforce https”代码。但是,当我将代码添加到我的.htaccess文件时,我的浏览器会抱怨它无法完成请求。如何在同一个文件中同时具有重写规则?
RewriteEngine On
#redirect to index.php as appropriate
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
#enforce https
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
答案 0 :(得分:2)
重写为switch (item.getItemId()) {
case R.id.menu_starred_add:
isStopSaved = false;
invalidateOptionsMenu();
break;
case R.id.menu_starred_remove:
isStopSaved = true;
invalidateOptionsMenu();
break;
}
的规则有一个正则表达式:index.php
,它匹配所有内容。这包括您想要重定向的任何内容。您需要在路由规则之前获得重定向规则。此外,您需要确保index.php中的任何内容都不会将浏览器重定向回非SSL:
^(.+)$