0

I always used the following rule to manage urls:

Options +FollowSymLinks  
RewriteEngine On  
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^.*$ ./urlredirect.php

With this I could easily check with php which page the user was trying to access.

Now I got a site that requires https on all pages. Here is the basic solution to this:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

My problem now is that I cannot get both working simultaneously. I know very little of mod-rewrite and regular expressions.

Any help would be greatly appreciated.

0

1 Answer 1

1

From the Apache docs: HTTP to HTTPS https://wiki.apache.org/httpd/RewriteHTTPToHTTPS

So you'd need the conditional, then the rule for each.

Options +FollowSymLinks  
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d

RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^.*$ ./urlredirect.php

RewriteCond %{HTTPS} off

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
1
  • I cannot believe it worked, I literally had every line just in different order. Wouldn't have guessed order mattered. Thanks
    – Nightwolf
    Commented Aug 18, 2015 at 21:37

Not the answer you're looking for? Browse other questions tagged .