4

当我到达 urlhttp://www.example.com/payments/add/2时,它应该会自动重定向到 https://www.example.com/payments/add/2.
注意:我已经在我的服务器上安装了 ssl。

if($this->params['action']=='add' && $this->params['controller']=='payments') 
    { $this->redirect('https://' . env('SERVER_NAME') . $this->here); }

该代码不起作用。请帮忙

4

1 回答 1

1

尝试这个

Options +FollowSymlinks
RewriteEngine On
RewriteBase /

#redirect www.mydomain.com to mydomain.com (or any other subdomain)
RewriteCond %{HTTP_HOST} !^mydomain.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [L,R=301]

#force https for certain pages    
RewriteCond %{HTTPS} !=on
RewriteRule ^(page1\.php|page2\.php|page3\.php|page4\.php)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
于 2013-06-06T04:59:09.217 回答