Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

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]
share|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 –  JF Dion Oct 21 '10 at 13:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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