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.

Nightwolf
  • 121
  • 1
  • 6

1 Answers1

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}
radiks32
  • 101
  • 2
  • I cannot believe it worked, I literally had every line just in different order. Wouldn't have guessed order mattered. Thanks – Nightwolf Aug 18 '15 at 21:37