Jump to content

StevenOliver

Members
  • Content Count

    55
  • Joined

  • Last visited

  • Days Won

    1

StevenOliver last won the day on November 25 2018

StevenOliver had the most liked content!

Community Reputation

5 Neutral

About StevenOliver

  • Rank
    Regular Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. StevenOliver

    HTTP to HTTPS except for ONE PAGE

    I agree w/ Requinix's position that "If anything an API needs to be HTTPS." However, for academic purposes, I'd like to know if any improvements can be made on the .htaccess code. Thank you.
  2. StevenOliver

    HTTP to HTTPS except for ONE PAGE

    Thank you kindly for your suggestions. My web host will only allow .htaccess directives; they will not do anything special on the config level :-) I do as much testing as I possibly can before posting here -- in this case ,over two weeks of daily tests, and I simply cannot find a way to make this code any better. If anyone can improve upon my code, I sure would appreciate it.
  3. My API page ("example.com/api.php") will be accessed by a 3rd party 1000+ times per second and I want it exempt from my .htaccess RewriteRule/RewriteCond's. Currently my RewriteRule forces "non-www to www" and "non-https to https" using this code: RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\.example.com\.com$ RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] For "speed" purposes (to avoid the compounded microtimes of rewriting 1000+ queries per second) would this be the correct, most efficient, and fastest code (the API page need not be HTTPS): RewriteCond %{REQUEST_URI} !^/api.php RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\.example.com\.com$ RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] Thank you!!
  4. StevenOliver

    3 Redirects: https, www, and root

    I have a followup question. I'm thinking it belongs in a new thread, so I'll try creating a new thread :-)
  5. StevenOliver

    3 Redirects: https, www, and root

    No sense.... just makes no sense.... now the redirect is working. And it is working on ALL my sites. There is absolutely 100% no reason it should stop working, then all of a sudden *after* I post my question here it suddenly starts working.... no sense. Perhaps I'll go out on a limb and say it's browser caching, because I have a 30-day mod_expires directive in my htaccess. However, I did keep my browser's cache cleared between tests.... I wonder if it's possible that Apache, itself, was sending out cached results? Or my IP caches pages? It's not my area of expertise, so I'm just guessing.
  6. StevenOliver

    3 Redirects: https, www, and root

    No, nothing changed. In about an hour I'll be at my other computer, and I'll try a scientific test: I'll place the same code on 2 different webhost's servers using fresh blank .htaccess files, and newly created "test" subdirectories with a "hello world" index file in each one. Then I'll try again and see if http://example.com/testdirectory redirects to http://www.example.com/testdirectory/ I'll come back here and post the results. Thank you.
  7. StevenOliver

    3 Redirects: https, www, and root

    edit: (update): Because I no longer need the "index.html to /", this is the current code: RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\.example\.com$ RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] However, the problem is this code forgets to force the "www" when inputting a URL like "example.com/directory" example.com/directory resolves to https://example.com/directory/ instead of the desired "https://www.example.com/directory/"
  8. StevenOliver

    3 Redirects: https, www, and root

    I just discovered a problem though. The redirects work most of the time.... for example: http://example.com/merchandise.html correctly redirects to https://www.example.com/merchandise.html However, http://example.com/blog redirects to http://example.com/blog/ (just adds a trailing slash but no https) -and- Erratic results using same browser, clearing browser's cache inbetween tests: example.com/blog sometimes redirects to https://www.example.com (omits the subdirectory) http://example.com/blog sometimes redirects to example.com/blog (omits the 'http' entirely, doesn't add trailing slash) example.com/blog sometimes redirects to example.com/blog./ (just adds a trailing slash, but no https) hmmm....
  9. StevenOliver

    3 Redirects: https, www, and root

    Requinix, thank you very much! That is fantastic!! I know it's a week later.... but I purposely didn't check back for a few days because I wanted to see what I could come up with all by myself :-) The goal was twofold 1. No more than one redirect. 2. Least amount of strain on Apache. Here's what I came up with: RewriteCond %{REQUEST_URI} /index\.html$ RewriteRule (.*?)(index\.html)?$ https://www.example.com$1 [NE,R=301,L] RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\.example\.com$ RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] And just now I saw your reply. My code has 5 lines. Your code has 4 lines. You win! You beat me! I'll use your code, less lines of code means less work for the Apache server. Thank you!!!
  10. Hello. To redirect "non-www to www" and "non-https to https," I found this efficient three-liner: RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\.example\.com$ RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] I would also like to redirect /index.html to root, what's the best way? (By "best," I mean fewest redirects and least strain on Apache.) Examples: http://example.com/data.html redirects to https://www.example.com/data.html http://example.com/index.html redirects to https://www.example.com/ Thank you.
  11. StevenOliver

    cURL in background

    Thank you!! That's perfect. That's the only thing I neglected to try -- modifying the code to process XML on the server. (Why why WHY don't I think of these things?! 😀)
  12. StevenOliver

    cURL in background

    Thank you -- I think that will work perfect.... but made a mistake: the 3rd party data I am accessing is in XML format: <merchandise> <apiversion>4.0</apiversion> <items> <item> <name>Hammer</name> <price>7.50</price> <currency>USD</currency> </item> </items> </merchandise> I'm not sure how to modify the jQuery in your code to parse XML (the "$().ready(function()" portion). Simply changing "JSON" to "XML" or, var txt = resp["<price>"] doesn't work. I found some "solutions" on Google, but I would rather use concise style of scripting. How would I access, for example, the "price" in the XML?
  13. StevenOliver

    cURL in background

    I envision running code in the background without slowing my own PHP page render. This code accesses optional "Additional Information" via a 3rd party server API ("www.example.com/Additional_Information.php?SKU=1234567"). Unfortunately, it takes a full 10 seconds to retrieve the data from the 3rd party server, and, not all visitors will need this "Additional Information." My own server is fast -- it retrieves mySQL data from my server and renders the result to the Visitor in less than 4 milliseconds. Because it takes an average Visitor about 10 seconds to actually READ my entire page (description, photos, etc.), this would be a perfect time to run a script in the background so that if the Visitor chooses to click the "Additional Information" link, the data will already be available (because the background script would run in the background and post its results to my own mySQL server while the Visitor was busy reading). I've been studying asynchronous cURL calls, opening sockets, forking cURL, and even using cURL to call another cURL script on my server. These seem to slow down my PHP page render. Because not all visitors will want this "Additional Information," I don't want to slow my webpage down for everyone. Is there a way to have code 'truly run in the background' and post its result to my super-fast mySQL server, so if a Visitor does click on the "Additional Information" link, they'd get instant results from my own server?
  14. StevenOliver

    Display ALL records GROUP by Year/Month/Day with SUM

    Barand, Wow! Thank you -- that is fantastic code! I'm going line by line familiarizing myself with proper PDO code. For example, new DateInterval('P1Y') sets it to a period of 1 year, setTime(0,0, 0) sets the time ("timer") to zero. I'm now working on trying to understand how and why this line of code works: "$summary->execute([$start_date])" What worries me is that I never would have thought to do that (I wouldn't have made the leap to knowing that the StartDate input parameter could go in there). I guess that's why they call programming languages "languages" ... because analogous to learning a language, one might ponder, "How would I have known to call an apple an 'apple,' or, an orange an 'orange.'" You just do it! And do it over and over again until it becomes natural and second-nature. Thank you again!!
  15. StevenOliver

    Display ALL records GROUP by Year/Month/Day with SUM

    Using the aformentioned code, these statements work but I don't know how to properly nest them whereby the nested Prepared Query uses data retrieved by first Prepared Query: // Statement One $stmt = $db->prepare(" SELECT YEAR(timestamp_column) as yr , MONTH(timestamp_column) as mno , MONTHNAME(timestamp_column) as mth , DAY(timestamp_column) as da , SUM(salesPrice) as total FROM mysales GROUP BY yr, mno ORDER BY timestamp_column desc; "); // Statement Two $stmt2 = $db->prepare(" SELECT DAYNAME(timestamp_column) as dana , usedPrice FROM mysales WHERE MONTH(timestamp_column) = 11 // hard-coded month AND YEAR(timestamp_column) = 2018 // hard-coded year ORDER BY timestamp_column desc; "); // This works for first statement: $stmt->execute(); $result = $stmt->get_result(); while($row = $result->fetch_assoc()) { echo $row["mth"].'....'.$row["yr"].'...'.$row["total"].'<BR>'; } // This works for second statement: $result2 = $stmt2->get_result(); while($row2 = $result2->fetch_assoc()) { $stmt2->execute(); echo $row2["dana"].'...'.$row2["salesPrice"].'<BR>'; } Nesting them like this "somewhat" works.... but 1.) Seems inefficient, and just plain wrong to execute "$stmt2->execute();" and "$result2 = $stmt2->get_result();" inside a 50000-record "while loop." 2.) Only works for a "hard-coded" month and year (don't know how to pull data retrieved from first Statement.... e.g. hard-coded year "2018" works, but "$row['yr']" doesn't) I don't know what to do...
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.