I'm looking to put a web application in production and I was wondering a few things about htaccess.

Here is my htaccess (the default htaccess provided by Zend Framework) :

SetEnv APPLICATION_ENV production

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

I would have liked to add two things in there, first a condition based on the APPLICATION_ENV to force SSL connection, but only in production (other possible values are development, testing and staging). The other thing I would have liked to set up is a redirection to the corresponding error action in the error controller based on the HTTP request error number.

I am not looking for a full answer, but at least where I need to start to be able to achieve my goals.

link|improve this question
feedback

1 Answer

up vote 0 down vote accepted

Here's a mod_rewrite cheatsheet and environment variable debugging HowTo for starters (nice supplement to the rather-sparse Apache mod_rewrite docs, IMHO).

Your solution to the production/https task may look a bit like this:

RewriteEngine on

RewriteCond %{ENV:APPLICATION_ENV} ^production$
RewriteCond %{HTTPS} !^on$
RewriteRule .* https://%{HTTP_HOST}/$1 [R=301,L,QSA]
link|improve this answer
I have yet to try it on my Production server, but so far, with the little knowledge i have on htaccess, it makes sense – Jeff D Oct 21 '10 at 13:36
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.