read

I use CodeIgniter a lot. Pretty much all the time. It’s an excellent platform for rapid and disciplined PHP development.

I have recently started working with Gandi.net a very well-specified and reasonably-priced domain- and web-hosting service based in France. This on the recommendation of the Bristol-based UnderScore [_] network.

There is one problem however. Up until now whenever I have tried to rejig CodeIgniter so that it doesn’t push all links through index.php the site has been left delivering 404s. Not very useful.

I’ve spent about three days picking through this and I’ve come to the following conclusions:

1) Varnish doesn’t always play nice with CodeIgniter - it seems to cause problems when you have lots of custom routing.
- there is a way to turn Varnish off in your .htaccess file

2) The standard .htaccess codes don’t generally work very well on Gandi.net

I have managed to pull together a fully-functioning .htaccess file that works well on Gandi.net. Here it is:


# temporarily disable Varnish to make it easier to test changes

Header add Cache-Control "max-age=1"

RewriteEngine On

# Existing files and directories remain accessible

RewriteCond %{REQUESTFILENAME} -f [OR]
RewriteCond %{REQUEST
FILENAME} -d
RewriteRule ^.* - [L]

# Redirect the rest

RewriteCond $1 !^(index.php|public|assets|robots.txt)
RewriteRule ^(.*)$ /index.php?/$1 [QSA,L]


I hope this helps anyone else who is dealing with the same issues.

Blog Logo

Robin Layfield

Cotswolds-based web developer digs CodeIgniter, Laravel, PHP, jQuery, Raspberry Pi & MySQL. Makes a living cutting code into tiny bits.


Published

Image

UltraSimplified blog

Thoughts from the other end of the wire.

Back to Overview