aebstract Posted March 14, 2008 Share Posted March 14, 2008 What is the best way to force the url to an https prefix vs an http? I'm thinking mod rewrite but I can't figure out a way to do it correctly, what I currently use in my rewrite is: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([[:alnum:]_]+)/$ /index.php?page=$1 [NC,L] RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2 [NC,L] RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2&var2=$3 [NC,L] This is on an apache server, perhaps there is another way of doing this or someone knows an easy way to do it with rewrite? Quote Link to comment Share on other sites More sharing options...
Demonic Posted March 14, 2008 Share Posted March 14, 2008 if ($_SERVER[HTTPS]!="on") { $strURIName=getenv("REQUEST_URI"); header ("Location: https://$SERVER_NAME$strURIName"); exit; } http://www.google.com/search?q=force+https%2Cphp&rls=com.microsoft:en-us&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1&safe=active Quote Link to comment Share on other sites More sharing options...
aebstract Posted March 14, 2008 Author Share Posted March 14, 2008 Works great, thanks. I did check google btw, I searched many different topics and found a lot on mod rewrite (none of which seemed like it would even work correctly) but this helped a lot. Thanks. Quote Link to comment Share on other sites More sharing options...
Demonic Posted March 14, 2008 Share Posted March 14, 2008 No problem Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.