PHP - .htaccess Question, Http To Https?
Hello, When I had a piece of coding done for me, the .htaccess looked like this: RewriteEngine On RewriteRule ^([^/]*)\.html$ index.php?pagina=$1 [L] RewriteCond %{HTTP_HOST} ^website.com [NC] RewriteRule ^(.*)$ http://www.website.com/$1 [L,R=301,NC]
But this was in the http era, now my host has provided me with a SSL and I want to use https. I asked the guy who made it for me but he couldn't remember what to do with it as I had this programmed by him over 6 years ago.
Basically the coding is some sort of semi cms system as an alternative to iframes in .html pages, the .php pages are converted to .html. Thanks! Similar TutorialsHi guys.. i am not very sure where to post about this issue but im giving a try and hope to get some ideeas where this might come maybe. So i have a small website with a members database.. the website itself it has SSL and works properly on a https connection. The problem comes when a member tries to access via http. Unfortunetaly on a page i have to keep it http due to some ads that i display there and dont work on https. If a member logs in and surfs the website via https everything is working perfectly.. but when he changes and tries to access via http he automatically gets logged out.. if he tries to login via http he also cant and gets an error with an invalid token. So basically i think my database cant connect when accessed by http.. Any of you ever encountered this issue ? Or maybe have some ideeas where this issue is coming from ?
Thanks and any ideea or help very appreciated It seems to me that this should be easy, but I can't find it in the manual or the on the web, and the values in $_SERVER don't suggest anything. Context: script A loads script B using HTTPS. Now script B has to load resources (images, style sheets, etc). Browsers often object to HTTP references from a script run by an HTTPS request, so script B should generate URLs that use HTTPS. Thus it has to know that it was loaded with HTTPS. I can do this by brute force if I have to (defining a "protocol" constant in the script itself), but I'd rather make the test automatic. Okay, my organanization has a page that we really need to autodirect to https:// in case anyone manually types in the http:// version. I've tried this (among many others) and it just sits there like a knot on a log: Code: [Select] <?php header( "Location: https://www.mywebsite.com/myfile.php" ) ; ?> Any ideas? It just simply doesn't redirect. It just sits there in its http:// format. I've also tried numerous other methods. None of them worked, either, but this is the simplest. Thanks! This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=321972.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=333590.0 Trying to run a simple program that, when submitted, stores the username and password as cookies. When clicking Submit, I get the error "HTTP Error 405 - The HTTP verb used to access this page is not allowed". If the username and password fields are left blank when submitting it's suppose to give a message to enter a username and password, but, I still get that error message. HTML form: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Week 1 Project--Cookies</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <form action="cookie1.php" method="post"> <h2 align="center">Cookies</h2> <br /> <div> <p>Enter your username and password and click "Submit":</p><br /> <p>Username:<input type="text" name="username" size="20"></p> <p>Password:<input type="text" name="password" size="20"></p> </div> <br /> <div><input type="submit" name="submit" value="Submit" /></div> <br /> <div> <input type="reset" name="Reset" value="Start Over" /> </div> </form> </body> </html> PHP file: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Cookie File</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <div> <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { setcookie('username', $_POST['username'], time() + 2592000); setcookie('password', $_POST['password'], time() + 2592000); } if(($_POST['username'] == "") || ($_POST['password'] == "")) { print "You must enter both a username and password. Press the Back button on your browser and try again."; } else if (isset($_COOKIE['username'])) { print "Welcome, " .$_COOKIE['username']; } ?> </div> </body> </html> How do I only redirect the page when index.php is present? so i have a number of websites on a server all work fine but when i put https://
in front of the other sites on the website's it redirects to another site on the server without changing domain name.
example:
http://www.example.com
works fine
https://www.example.com
shows another site on the server
how can i stop this?
i tryed mod rewrites in htaccess but somehow isnt working?
Anyone know how to force URL with SSL with www.
<rewrite> <rules> <rule name="Redirect to HTTPS" stopProcessing="true"> <match url="(.*)" /> <conditions><add input="{HTTPS}" pattern="^OFF$" /> </conditions> <action type="Redirect" url="https://www.site.com/{R:0}" redirectType="SeeOther" /> </rule> </rules> </rewrite>Please check the sample. I'm trying to determine the best way to provide HTTPS access to a web application that I'm building. I know that you can use the following code to redirect anyone manually accessing the http version of an https page: Code: [Select] if($_SERVER["HTTPS"] != "on") { header("HTTP/1.1 301 Moved Permanently"); header("Location: "https://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]); exit(); } I have also heard that you could use mod_rewrite in Apache to achieve similar results. The entire web application should use https so I just want to make sure that I'm setting this up correctly. Feedback on the best approach or other suggestions would be very helpful. Thanks in advance. Hello,
I cannot work out this one.
I am loading a css file on an https page as:
<link rel="stylesheet" type="text/css" href="/assets/fa687e60/jui/css/base/jquery-ui.css" />
But using the chrome element tool I see this error:
The page at 'https://mysite.com/deal/create' was loaded over HTTPS, but displayed insecure content from 'http://mysite.com/cs...bf9ee_1x400.png': this content should also be loaded over HTTPS.
Now I went in the css file and the code is like that:
.ui-state-highlight, .ui-widget-content .ui-state-highlight, Hi Everyone,
I am really struggling with this.....Cannot find a solution anywhere.
I have a website with SSL installed.
I would like to force SSL on the whole website but not on 2 urls.
If my whole site is https://mysite.com
and the 2 urls to disable from the SSL a
http://mysite.com/hotels
http://mysite.com/weather
How can I do it via htaccess please?
Thank you so much,
Ben
I am using file_get_contents with a url (http) to screen scrape certain web pages that are publicly accessible. However there are certain web pages (https) that require me to use an x509 certificate stored in my browser to make them visible. I would like to scrape them too. How would I scrape them using a php script? Thanks in Advance. Should I always use HTTPS when users are inputting credit card numbers & billing info? Do you know any sites that don't use HTTPS? I just want to know if it's a total no-no for web applications. Discuss. Apache https setup!
Okay so i made my own SSL certificate for my localhost using these commands
OpenSSL: ( CMD > c:\xampp\apache\bin\openssl )
req -config c:\xampp\php\extras\ssl\openssl.cnf -new -out jobnow.csr -keyout jobnow.pem rsa -in jobnow.pem -out c:\jobnow.key x509 -in jobnow.csr -out jobnow.crt -req -signkey c:\jobnow.key -days 369when asked for common name type your ip address. Then i install import the certificate to certmgr.msc Restate Apache https//192.168.0.14 - Doesnt work 192.168.0.14 - Works fine Apache error log: [Wed Sep 10 12:05:41.299000 2014] [ssl:warn] [pid 7840:tid 260] AH01909: RSA certificate configured for localhost:80 does NOT include an ID which matches the server name [Wed Sep 10 12:05:41.301000 2014] [ssl:warn] [pid 7840:tid 260] AH01909: RSA certificate configured for 192.168.0.14:443 does NOT include an ID which matches the server name [Wed Sep 10 12:05:41.301000 2014] [ssl:warn] [pid 7840:tid 260] AH01915: Init: (localhost:80) You configured HTTPS(443) on the standard HTTP(80) port! [Wed Sep 10 12:05:41.373000 2014] [co warn] [pid 7840:tid 260] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run? [Wed Sep 10 12:05:41.616000 2014] [ssl:warn] [pid 7840:tid 260] AH01909: RSA certificate configured for localhost:80 does NOT include an ID which matches the server name [Wed Sep 10 12:05:41.617000 2014] [ssl:warn] [pid 7840:tid 260] AH01909: RSA certificate configured for 192.168.0.14:443 does NOT include an ID which matches the server name [Wed Sep 10 12:05:41.617000 2014] [ssl:warn] [pid 7840:tid 260] AH01915: Init: (localhost:80) You configured HTTPS(443) on the standard HTTP(80) port! [Wed Sep 10 12:05:41.659000 2014] [mpm_winnt:notice] [pid 7840:tid 260] AH00455: Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9 configured -- resuming normal operations [Wed Sep 10 12:05:41.659000 2014] [mpm_winnt:notice] [pid 7840:tid 260] AH00456: Apache Lounge VC11 Server built: Nov 21 2013 20:13:01 [Wed Sep 10 12:05:41.659000 2014] [co notice] [pid 7840:tid 260] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache' [Wed Sep 10 12:05:41.661000 2014] [mpm_winnt:notice] [pid 7840:tid 260] AH00418: Parent: Created child process 7032 [Wed Sep 10 12:05:42.319000 2014] [ssl:warn] [pid 7032:tid 272] AH01909: RSA certificate configured for localhost:80 does NOT include an ID which matches the server name [Wed Sep 10 12:05:42.321000 2014] [ssl:warn] [pid 7032:tid 272] AH01909: RSA certificate configured for 192.168.0.14:443 does NOT include an ID which matches the server name [Wed Sep 10 12:05:42.321000 2014] [ssl:warn] [pid 7032:tid 272] AH01915: Init: (localhost:80) You configured HTTPS(443) on the standard HTTP(80) port! [Wed Sep 10 12:05:42.645000 2014] [ssl:warn] [pid 7032:tid 272] AH01909: RSA certificate configured for localhost:80 does NOT include an ID which matches the server name [Wed Sep 10 12:05:42.646000 2014] [ssl:warn] [pid 7032:tid 272] AH01909: RSA certificate configured for 192.168.0.14:443 does NOT include an ID which matches the server name [Wed Sep 10 12:05:42.646000 2014] [ssl:warn] [pid 7032:tid 272] AH01915: Init: (localhost:80) You configured HTTPS(443) on the standard HTTP(80) port! [Wed Sep 10 12:05:42.688000 2014] [mpm_winnt:notice] [pid 7032:tid 272] AH00354: Child: Starting 150 worker threads. [Wed Sep 10 12:05:54.589000 2014] [authz_co error] [pid 7032:tid 1652] [client 192.168.0.14:3112] AH01630: client denied by server configuration: C:/xampp/htdocs/ [Wed Sep 10 12:05:54.682000 2014] [authz_co error] [pid 7032:tid 1652] [client 192.168.0.14:3112] AH01630: client denied by server configuration: C:/xampp/htdocs/favicon.icoIt says my server name does not match, So i changed the server name to: ( httpd-ssl.conf ) around line 80 ServerName 192.168.0.14:443 DocumentRoot to my httpd.conf document root My .key is in apache/conf/ssl.key my crt is in apache/conf/ssl.crt I hope this helps someone else! i had to post this after how much trouble it was causing me! Hello I have problem on redirecting the site to https when it comes to "www.site.com".
I made this
<rules> <rule name="Redirect site.com to www" patternSyntax="Wildcard" stopProcessing="true"> <match url="*" /> <conditions> <add input="{HTTP_HOST}" pattern="site.co" /> </conditions> <action type="Redirect" url="https://www.site.co/{R:0}" /> </rule> </rules>In this sample when I try to access the site through "site.com" it redirect to " https://www.site.com " but when I access the site to www.site.com the https doesn't appear. I am relatively new to php and am working on a small project for myself where I need to make a secure https connection to my supplier's web server and have to pass a data string to the server using the POST method. I've googled 'using php to make https connections', but am having difficulty getting started in learning about this process. The PHP manual is somewhat too 'techie' for my level. Does anyone have a suggestion where I can get started? Thanks. Not sure if my title line was worded correctly, but here is what I am trying to understand... I need to hook my website up to a payment gateway to accept credit cards. After I package up the customer's payment details and send the payment gateway an XML string, their server supposedly sends back a request for more information OR it indicates a Pass/Fail message. This is where I am getting lost. If I send data over HTTPS using POST, then how am I supposed to receive a message back from them? It's not like we are on the telephone and there is a "live" link between my web server and theirs?! Can someone please explain how this works? Thanks, Debbie This is a two part question... my previous post was surrounding an issue with Sessions, now I was told that it may be a server side issue so I contacted my host provider who said to me that sessions cookies REQUIRE https?? now this can't be valid because I've had no issues with sessions prior to this week - second part of this is, is there something I'm missing with maybe an updated versions?
PS: yes, i'm new and simply trying to learn... (Trying to get my brain back into this old problem which I fixed but want to re-code a better way...) So I was having problems with getting some browser error when people would go to checkout because the page logo was coming from an HTTP source and the page was an HTTPS page. I created a "config" file and had this code... Code: [Select] <?php define('ENVIRONMENT', 'development'); //define('ENVIRONMENT', 'production'); // Secure Web Server Root define('SECURE_WEB_ROOT', ENVIRONMENT === 'development' ? 'http://local.dev3/' : 'https://www.mysite.com/'); ?> Then in my page I had... Code: [Select] <div id="header"> <a href="<?php echo WEB_ROOT ?>index.php"> <img id="logo" src="<?php echo SECURE_WEB_ROOT ?>images/mylogo_200x50.png" width="200" alt="My Logo" /> </a> </div> Is there a better way to do this and eliminate my Config file which is no longer needed since I learned how to create a "Virtual Server"? Debbie |