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? Link to comment https://forums.phpfreaks.com/topic/96181-force-https/ 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 Link to comment https://forums.phpfreaks.com/topic/96181-force-https/#findComment-492373 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. Link to comment https://forums.phpfreaks.com/topic/96181-force-https/#findComment-492376 Share on other sites More sharing options...
Demonic Posted March 14, 2008 Share Posted March 14, 2008 No problem Link to comment https://forums.phpfreaks.com/topic/96181-force-https/#findComment-492382 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.