Reputation: 1987
I am looking for a .htaccess file which can do the following, I've managed to get each function to work individually but not together.
Requirement no 1: All HTTP traffic is redirected to HTTPS
Requirement no 2: All HTTPS URLs are directed to index.php?url_params=
I either end up with an endless loop on the request_uri or I end up with server error:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTPS} off
#RewriteCond %{HTTP:X-Forwarded-Proto} = http
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ ./index.php?url_path=$1 [L,NC,QSA]
So if someone was to type in "http://www.example.com/page1" it would redirect to "https://www.example.com/page1" and then "https://www.example.com/page1" is sent to index.php with page1 sent as a url param
Thanks
D
Upvotes: 1
Views: 64
Reputation: 785058
Try these rules:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url_path=$1 [L,QSA]
Clear your browser cache before testing this change.
Upvotes: 1