• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pros and Cons of Putting Static HTML into /public_html

#1
[eluser]joneslee[/eluser]
After working with CI for few months, I realized that it's quite time-consuming to convert all static pages into MVC model because designers who works with me do not know what CI is nor what PHP is. So all they do is everything into /public_html (By taking advantage of mod_rewrite and set $config['index_page']='' in config.php). Only pages with dynamic content will be put into Views folder. I could see the pros is that designers do not need to know code to work with the system and less time for me to maintain those static pages. I would love to hear opinion from all experts out on how bad of doing so and is there a better way to solve this inconsistency?

Many thanks

#2
[eluser]gtech[/eluser]
static pages in a static folder kinda make sense to me, else you would have the overhead of having to load a view inside a controller for each static page.


Another solution:

[url="http://codeigniter.com/wiki/site_migrate/"]http://codeigniter.com/wiki/site_migrate/[/url] (Thanks to [url="http://ellislab.com/forums/member/39899/"]sophistry[/url])


My understanding is that this code will allow you to drop your static files in the views directory (giving them a php extension). So when a url request is received the code will check to see if there is a controller if not it will load the view page.

this makes use of the CI _remap() function in the [url="http://ellislab.com/codeigniter/user-guide/general/controllers.html#remapping"]controller[/url] code, which enables you to override the default behaviour.

If you wanted to load standard header and footer views for each static page you could easily modify the code.

#3
[eluser]Dr. Seuss[/eluser]
I have a similar problem: I have placed my static html in a peer directory, like so:

|
+ system
+ static
+ user_guide
.htaccess
index.php

...and have placed this in my .htaccess file:

RewriteEngine On

RewriteRule ^([a-z]+)\.html$ /static/$1.html
RewriteRule ^([a-z0-9])\.gif$ /static/images/$1.gif

My problem seems to be that I cannot get my images to display within the pages. Any ideas as to what I am doing wrong?

#4
[eluser]Dr. Seuss[/eluser]
Well, just having that in the .htaccess breaks the "normal" way that CI works, so I have modified it thus:

RewriteEngine on

RewriteRule ^([a-z]+)\.html$ /static/$1.html [L]
## RewriteRule ^([a-z0-9])\.gif$ /static/images/$1.gif [L]

RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

...which restores CI's "normal" MVC processing, but now no longer retrieves the static .html files.

#5
[eluser]Dr. Seuss[/eluser]
SOLVED: Here's where I ended up.

RewriteEngine On
RewriteRule ^(application) - [F,L]

DirectoryIndex /static/index.html

RewriteRule ^([a-z0-9_-]+)\.html$ /static/$1.html [L]
RewriteRule ^images/([a-z0-9_-]+)\.gif$ /static/images/$1.gif [L]
RewriteRule ^images/([a-z0-9_-]+)\.jpg$ /static/images/$1.jpg [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.