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

I'm afraid my knowledge of .htaccess files is really sketchy and my understanding of regular expressions, and the like, is even worse. I was hoping I might find some guidance here.

I'm running a cakePHP application on my server, and I am in the process of switching it to run entirely over SSL. I have created a 301 redirect rule to force any non-SSL requests over to SSL.

cakePHP already has a rewrite rule (though its a 302 rather than 301!) of its own to force everything through the cake dispatcher, where all of the native routing is handled.

The following two separate rules are working at the moment:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTPS} !^on$
    RewriteRule (.*) https://www.website.com/cakeapp/$1 [R=301,L]       

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>

However, it results on a 301 redirect, followed by a 302 redirect before the actual SSL page loads.

Is there a way to combine the two rules above, into a more efficient one, resulting in a single 301 redirect?

Thanks very much for your help!

share|improve this question
    
Where's the 302 redirect sending the user to? –  Shane Madden Jan 27 '13 at 8:39
    
Sorry! My mistake, the 302 redirect only occurs if, in cake, I don't specify the default action (by putting only e.g. site.com/controller). –  Rich Jan 28 '13 at 8:39
    
So would you want to be able to configure a 'default' in those cases? Is there a specific set or pattern to the URLs that get the second redirect? –  Shane Madden Jan 28 '13 at 17:15

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.