将带有index.php的所有URL重定向到/同时重定向http-> https

时间:2016-07-19 23:17:23

标签: apache .htaccess redirect

旧网址如下:

http://example.com/index.php/whatever/page

or

http://www.example.com/some-url-that-doesnt-begin-with-index/

新网址将是:

https://example.com/index.php/whatever/page

or

https://example.com/some-url-that-doesnt-begin-with-index/

这就是说当前的旧网址:

  1. 可能包括也可能不包括www
  2. 都是http
  3. 他们中的大多数都在域之后和URL的其余部分之前都有index.php,但不是全部 他们。
  4. 我只是在寻找.htaccess规则来实现这一目标,但没有实现多个重定向。

1 个答案:

答案 0 :(得分:-1)

要将http请求重定向到https,您可以使用此

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ 
RewriteRule . https://%1%{REQUEST_URI} [L,R]