Codeigniter: how to serve static html pages in the context of codeigniter

Hello everyone I want to serve some static html pages in the context of codeigniter. I do not want to bypass the index.php file in base_url. But when I call the call in an HTML file, it sends a 404 error page. I appreciate any help on this topic from guys who are already solving this problem. Thanks for everything in advance.

I want to clarify these elements:

  • My real problem is to serve the PDF file for users to display in the browser only to save the PDF file. Therefore, I convert PDF to HTML files. The output is a directory with HTML files linked between them and with them / using the /, CSS, js buttons for navigation.
  • when I put this HTML-OUTPUT in the ci \ Docs \ HTML1 directory, I can access it with this url localhost / ci / docs / html1 / index.htm. But where I use localhost / ci / index.php / docs / html1 / index.htm, I get a 404 error page.
  • So, I moved the HMLT1 directory to the Application \ views directory. And I have the same error. My .htacces look like this:

    <IfModule mod_rewrite.c> RewriteEngine on RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA] </IfModule> 

Thank you guys for your help.

+4
source share
3 answers

Create a static HTML file as a view, and then just load the view:

 $this->load->view('static.html'); 

Then you can access this file as a regular controller. It all depends on how you configured your .htaccess.

+11
source

$ route ['your-page-url'] = "/ page / message / your-page-url";

In the "Page Controller" function:

 public function message($page = 'your-page-url') { $data['title']= 'Your Page Title'; $this->load->view('/header',$data); $this->load->view('pages/your-page-url'); $this->load->view('/footer'); } 
0
source

For me, I just add the folder name for my static html pages to .htaccess to exclude it from regexp, as shown below, and it works. Just to exclude it from the rewrite URL in index.php

 RewriteEngine on RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|sitemap\.xml|static-html) RewriteRule ^(.*)$ index.php/$1 [L] 
0
source

All Articles