使用https

时间:2017-01-05 09:32:18

标签: .htaccess codeigniter redirect ssl mpdf

我正在为我的项目添加一个pdf函数,但是在完成后重定向函数我有一个奇怪的问题。

最初,它在localhost和不使用ssl证书的测试主机上运行良好,但它不能在与ssl证书关联的域上工作我不知道原因,当我应该开始时没有调试信息可以指导我。

没有ssl的工作代码:http://idev-inc.com/lab/rwahl.com/invoice 您必须预订酒店才能获得与您合作的链接,否则它会将您重新连接到主页。

此网址上的相同功能和回购:https://rwahl.com/ndmilestone/invoice

我查找了有关ssl重定向的最多线程,我更新了 .htaccess 指向以下内容:

RewriteEngine on

# Enforce SSL https://www. 
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
###
# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#####RewriteRule ^(.*)$ /ndmilestone/index.php/$1 [L]
RewriteRule ^(.*)$ /ndmilestone/index.php?/$1 [L,QSA]

我正在使用mpdf库来生成pdf文件,而这是 invoice_as_pdf函数

function invoice_as_pdf(){
$assumptiondata=Array();

$filename="invoice".time().rand(1,9);
// As PDF creation takes a bit of memory, we're saving the created file in 
// /downloads/reports/

$sub_folder="downloads/reports/$filename.pdf";
$pdfFilePath = FCPATH."/".$sub_folder;
$finalurl=base_url().$sub_folder;

// pass data to the view
if (file_exists($pdfFilePath) == FALSE){

ini_set('memory_limit','32M'); // boost the memory limit if it's low ;)
$this->theme->view('Admin/modules/global/invoice', $this->data, $this);
$html = $this->load->view('Admin/modules/global/idev_invoice_print', $data, true); // render the view into HTML

$this->load->library('pdf');

$mpdf = $this->pdf->load();

$mpdf=new mPDF('utf-8'); 
// $pdf->useAdobeCJK = true;
$mpdf->charset_in='UTF-8';
// Add a footer for good measure ;)
$mpdf->SetFooter($_SERVER['HTTP_HOST'].'|{PAGENO}|'.date(DATE_RFC822)); 


$mpdf->SetDirectionality('rtl');
$mpdf=new mPDF('ar','A4','','',32,25,27,25,16,13); 
$mpdf->SetDirectionality('rtl');
$mpdf->mirrorMargins = true;

$mpdf->WriteHTML($html); // write the HTML into the PDF

$mpdf->Output($pdfFilePath, 'F'); // save to file because we can

}

$this->load->helper('url');  // it is auto-loaded but I'm testing to call here also 

redirect($finalurl); //redirect to the new PDF 

}

pdf文件也成功生成,实际上我尝试了几种情况,但到目前为止我无法理解。 提前致谢。

0 个答案:

没有答案