Page 1 of 1

.htaccess for Test Site Data.

Posted: Sun 07 Mar 2021 1:10 am
by Phil23
Hi all,

As mentioned in another thread, I Planning to do a progressive upgrade here to the newer templates with test sites at

http://weather.inverellit.com/new/index.htm & http://weather.inverellit.com/legacy/

Was thinking I may be able to use the .htaccess file to have each test site point to the parent data, but it doesn't seem to work.

Am I doing it wrong or am I on the wrong track.

The last two commented RewriteRules art the ones I tried, but they don't seem to work.
The htaccess file resides in the //weather.inverellit.com directory.

Any suggestions?

Thanks

Phil.

Code: Select all

# This prevents web browsers or spiders from seeing your .htaccess directives:
<Files .htaccess>
	deny from all
</Files>

RewriteEngine On

RewriteRule ^console.htm$  davconvp2CU.php [NC,L]
RewriteRule ^press.png$    graphPress.php [NC,L]
RewriteRule ^temp.png$     graphTempOut.php [NC,L]
RewriteRule ^intemp.png$   graphTempInOut.php [NC,L]
RewriteRule ^hum.png$      graphHum.php [NC,L]
RewriteRule ^inhum.png$    graphHumIn.php [NC,L]
RewriteRule ^outhum.png$   graphHumOut.php [NC,L]
RewriteRule ^rain.png$     graphRrate.php [NC,L]
RewriteRule ^raint.png$    graphRain.php [NC,L]
RewriteRule ^solar.png$    graphSolar.php [NC,L]
RewriteRule ^uv.png$       graphUV.php [NC,L]
RewriteRule ^wind.png$     graphWind.php [NC,L]
RewriteRule ^windd.png$    graphWdir.php [NC,L]
RewriteRule ^windrose.png$ graphWindRose.php [NC,L]
# RewriteRule ^realtimegauges.txt$ http://weather.inverellit.com/realtimegauges.txt [NC,L]
# RewriteRule ^tempdata.json$ http://weather.inverellit.com/tempdata.json [NC,L]

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “alt-php71” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-alt-php71___lsphp .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

Re: .htaccess for Test Site Data.

Posted: Sun 07 Mar 2021 1:19 am
by Phil23
I assume is there is an answer to how it can be done it might be here

https://httpd.apache.org/docs/2.4/rewrite/flags.html

Bit out of my depth though.

Re: .htaccess for Test Site Data.

Posted: Sun 07 Mar 2021 2:18 am
by beteljuice
What does your <F12> 'network' say about the file grabs ?

Re: .htaccess for Test Site Data.

Posted: Sun 07 Mar 2021 3:02 am
by Phil23
beteljuice wrote: Sun 07 Mar 2021 2:18 am What does your <F12> 'network' say about the file grabs ?
If I enable the realtime gauges one & delete the on in /new I get...

Code: Select all

GET http://weather.inverellit.com/new/realtimegauges.txt?_=1615085967069 404 (Not Found).
Does the "." in .htaccess mean it only applies to the parent directory?

Edit:-

Tried copying the .htaccess down a level to /new & it returned this...

Code: Select all

GET http://weather.inverellit.com/realtimegauges.txt?_=1615086196538 net::ERR_TOO_MANY_REDIRECTS

Re: .htaccess for Test Site Data.

Posted: Sun 07 Mar 2021 3:26 am
by beteljuice
.htaccess simply means it's a 'hidden' file.

I can't see why your main redirect isn't working correctly, but when put in the sub directory (new) it does - They are BOTH doing something, they are interacting and causing the too many redirects error you have.

You can have .htaccess for each directory ... so try ...
comment out the entries in your main .htaccess

Create a new .htaccess for your \new directory:

Code: Select all

# This prevents web browsers or spiders from seeing your .htaccess directives:
<Files .htaccess>
	deny from all
</Files>

RewriteEngine On

RewriteRule ^realtimegauges.txt$ http://weather.inverellit.com/realtimegauges.txt [NC,L]
RewriteRule ^tempdata.json$ http://weather.inverellit.com/tempdata.json [NC,L]


Re: .htaccess for Test Site Data.

Posted: Sun 07 Mar 2021 6:33 am
by Phil23
Thanks Beteljuice,

That seem to work for realtimegauges.txt, so presume it will work for the others ones I actually upgrade CMX.

At this stage still not clear what will be uploaded when I turn off IncludeSTD.
Anyone know if that stops all the JSON files uploading as well?

Thanks

Phil.

Re: .htaccess for Test Site Data.

Posted: Tue 25 May 2021 11:07 pm
by Phil23
Finally back up to date again after finishing of the setup on a Reborn replacement laptop with Win10P to replace that failing Win8H.

Redirected Dir *.json > JsonList.txt & used that to build the following .htaccess file.

Code: Select all

# This prevents web browsers or spiders from seeing your .htaccess directives:
<Files .htaccess>
	deny from all
</Files>

RewriteEngine On

RewriteRule ^realtimegauges.txt$ http://weather.inverellit.com/realtimegauges.txt [NC,L]

RewriteRule ^airquality.json$ http://weather.inverellit.com/airquality.json [NC,L]
RewriteRule ^alldailydegdaydata.json$ http://weather.inverellit.com/alldailydegdaydata.json [NC,L]
RewriteRule ^alldailyhumdata.json$ http://weather.inverellit.com/alldailyhumdata.json [NC,L]
RewriteRule ^alldailypressdata.json$ http://weather.inverellit.com/alldailypressdata.json [NC,L]
RewriteRule ^alldailyraindata.json$ http://weather.inverellit.com/alldailyraindata.json [NC,L]
RewriteRule ^alldailysolardata.json$ http://weather.inverellit.com/alldailysolardata.json [NC,L]
RewriteRule ^alldailytempdata.json$ http://weather.inverellit.com/alldailytempdata.json [NC,L]
RewriteRule ^alldailywinddata.json$ http://weather.inverellit.com/alldailywinddata.json [NC,L]
RewriteRule ^alltempsumdata.json$ http://weather.inverellit.com/alltempsumdata.json [NC,L]
RewriteRule ^availabledata.json$ http://weather.inverellit.com/availabledata.json [NC,L]
RewriteRule ^dailyrain.json$ http://weather.inverellit.com/dailyrain.json [NC,L]
RewriteRule ^dailytemp.json$ http://weather.inverellit.com/dailytemp.json [NC,L]
RewriteRule ^graphconfig.json$ http://weather.inverellit.com/graphconfig.json [NC,L]
RewriteRule ^humdata.json$ http://weather.inverellit.com/humdata.json [NC,L]
RewriteRule ^pressdata.json$ http://weather.inverellit.com/pressdata.json [NC,L]
RewriteRule ^raindata.json$ http://weather.inverellit.com/raindata.json [NC,L]
RewriteRule ^solardata.json$ http://weather.inverellit.com/solardata.json [NC,L]
RewriteRule ^sunhours.json$ http://weather.inverellit.com/sunhours.json [NC,L]
RewriteRule ^tempdata.json$ http://weather.inverellit.com/tempdata.json [NC,L]
RewriteRule ^wdirdata.json$ http://weather.inverellit.com/wdirdata.json [NC,L]
RewriteRule ^websitedata.json$ http://weather.inverellit.com/websitedata.json [NC,L]
RewriteRule ^winddata.json$ http://weather.inverellit.com/winddata.json [NC,L]
I'm still processing the old templates at this point, but also have:-

http://weather.inverellit.com/new/index.htm

Which is working fine getting the data from the main directory,
but also have:-

http://weather.inverellit.com/legacy/

with the same .htaccess which is not reading data.

Notice the contents of the webfiles-legacy zip are dated back in February & not sure what current & compatible with the present data structure.
Do notice also that all the graph pages work to an extent, http://weather.inverellit.com/legacy/trends.htm indicating that it's the main data that's not being read.

Any thoughts?
I do intend to take on the new format, but it will be a while in getting the time to get it up how I want it.

Thanks

Phil.

Re: .htaccess for Test Site Data.

Posted: Wed 26 May 2021 9:36 am
by mcrossley
As per the release notes, if you want to continue using the legacy web site, then you will have to add the legacy .htm to Extra Web Files on newer releases.

The legacy web site processes and uploads each web page individually - it does not use the websitedata.json file. It does use the graph data json files - and I see the graph pages are working on your legacy site.

Re: .htaccess for Test Site Data.

Posted: Wed 26 May 2021 9:49 am
by Phil23
mcrossley wrote: Wed 26 May 2021 9:36 am As per the release notes, if you want to continue using the legacy web site, then you will have to add the legacy .htm to Extra Web Files on newer releases.

The legacy web site processes and uploads each web page individually......
The Template *T.htm files yes, as in my main site,
But as mentioned in the Wiki....

Code: Select all

FAQ
I want to keep the old web site look and feel, but also update to MX v3.10+
Well, good news (for now). The distribution zip file contains a folder named /webfiles-legacy.

This folder contains a "new" version of the original web site that uses the same data-driven approach of the new template. 
So you can enjoy the efficiency of the new single data file upload with the old look and feel.

Be aware though that these legacy files will no longer be maintained or updated, 
and at some stage will be removed from the distribution file.
It's thones file from the Zip in the distribution I have under http://weather.inverellit.com/legacy/
and per per below, it is not based on WebTags.

Code: Select all

<!DOCTYPE HTML>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="description" content="weather data">
  <meta name="keywords" content="Cumulus, weather, data, weather station">
  <title></title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="weatherstyle.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="content">
<h1><span class="cmx-location"></span></h1>
<h2 style="text-align: left; text-transform: none;" >&nbsp;Latitude&nbsp;<span id="cmx-latitude"></span>&nbsp;&nbsp; &nbsp;Longitude&nbsp;<span id="cmx-longitude"></span>&nbsp;&nbsp; &nbsp;Elevation&nbsp;<span id="cmx-altitude"></span></h2>
<!-- Almanac -->
<table style="width:100%;border-collapse: collapse; border-spacing: 0;" >
  <tbody><tr>
    <td class="labels">Dawn:</td>
    <td class="site_data" style="text-align: left;"><span id="cmx-dawn"></span></td>
    <td class="labels">Sunrise:</td>
    <td class="site_data" style="text-align: left;"><span id="cmx-sunrise"></span></td>
    <td class="labels">Moonrise:</td>
    <td class="site_data" style="text-align: left;"><span id="cmx-moonrise"></span></td>
    <td rowspan="3"><img src="images/moon.png" alt="Moon" width="64" height="64" style="margin: 0px 10px;" /></td>
  </tr>
  <tr>
    <td class="labels">Dusk:</td>
     <td class="site_data" style="text-align: left;"><span id="cmx-dusk"></span></td>
    <td class="labels">Sunset:&nbsp;</td>
    <td class="site_data" style="text-align: left;"><span id ="cmx-sunset"></span></td>
    <td class="labels">Moonset:</td>
    <td class="site_data" style="text-align: left;"><span id="cmx-moonset"></span></td>
  </tr>
  <tr>
    <td class="labels">Daylight:</td>
    <td class="site_data" style="text-align: left;"><span id="cmx-daylightlength"></span></td>
    <td class="labels">Day length:</td>
    <td class="site_data" style="text-align: left;"><span id="cmx-daylength"></span></td>
    <td class="labels">Moon Phase:</td>
    <td class="site_data" style="text-align: left;"><span id="cmx-moonphase"></span></td>
  </tr>
</tbody>
</table>
<!-- END Almanac -->
<p>Welcome to <span id="cmx-longlocation"></span>. </p>
<p>The weather station in use is the <span id="cmx-stationtype">, and these pages are updated
every <span id="cmx-interval"> minutes. The meteorological day used at this station ends at
<span id="cmx-rollovertime"></span>.</p>
<p><b>Forecast:</b> <span id="cmx-forecast"></span></p>
<table style="width:100%;border-collapse: collapse; border-spacing: 0;" >
  <caption>Conditions at local time <span id="cmx-time"></caption>
  <tr>
    <td colspan="4" class="tableseparator_temp">Temperature and Humidity </td>
  </tr>
  <tr class="td_temperature_data">
    <td>Temperature</td>
    <td><span id="cmx-temp"></span>&nbsp;<span class="cmx-tempunit"></span></td>
    <td>Dew&nbsp;Point </td>
    <td><span id="cmx-dew"></span>&nbsp;<span class="cmx-tempunit"></span></td>
  </tr>
  <tr class="td_temperature_data">
    <td>Windchill</td>
    <td><span id="cmx-wchill"></span>&nbsp;<span class="cmx-tempunit"></span></td>
    <td>Humidity</td>
    <td><span id="cmx-hum"></span>%</td>
  </tr>
  <tr class="td_temperature_data">
    <td>Heat Index</td>
    <td><span id="cmx-heatindex"></span>&nbsp;<span class="cmx-tempunit"></span></td>
    <td>Apparent Temperature</td>
    <td><span id="cmx-apptemp"></span>&nbsp;<span class="cmx-tempunit"></span></td>
  </tr>
  <!-- Solar data. If you don't have a solar sensor, you may wish to delete everything from here to the next comment -->
  <tr class="td_temperature_data">
    <td>Solar Radiation</td>
    <td><span id="cmx-SolarRad"></span>&nbsp;W/m&sup2;</td>
    <td>Evapotranspiration Today</td>
    <td><span id="cmx-ET"></span>&nbsp;<span class="cmx-rainunit"></span></td>
  </tr>
  <!-- End of solar data -->
  <tr class="td_temperature_data">
    <td>THW Index</td>
    <td><span id="cmx-THWindex"></td>
    <td>Temp change last hour</td>
    <td><span id="cmx-TempChangeLastHour"></span>&nbsp;<span class="cmx-tempunit"></span></td>
  </tr>
  <tr>
    <td colspan="4" class="tableseparator_rainfall">Rainfall</td>
  </tr>
  <tr class="td_rainfall_data">
    <td>Rainfall&nbsp;Today</td>
    <td><span id="cmx-rfall"></span>&nbsp;<span class="cmx-rainunit"></span></td>
    <td>Rainfall&nbsp;Rate</td>
    <td><span id="cmx-rrate"></span>&nbsp;<span class="cmx-rainunit"></span>/hr</td>
  </tr>
  <tr class="td_rainfall_data">
    <td>Rainfall&nbsp;This&nbsp;Month</td>
    <td><span id="cmx-rmonth"></span>&nbsp;<span class="cmx-rainunit"></span></td>
    <td>Rainfall&nbsp;This&nbsp;Year</td>
    <td><span id="cmx-ryear"></span>&nbsp;<span class="cmx-rainunit"></span></td>
  </tr>
  <tr class="td_rainfall_data">
    <td>Rainfall&nbsp;Last Hour</td>
    <td><span id="cmx-rhour"></span>&nbsp;<span class="cmx-rainunit"></span></td>
    <td>Last rainfall</td>
    <td><span id="cmx-LastRainTipISO"></td>
  </tr>
  <tr class="td_rainfall_data">
    <td>Rainfall&nbsp;Since&nbsp;Midnight</td>
    <td><span id="cmx-rmidnight"></span>&nbsp;<span class="cmx-rainunit"></span></td>
    <td>Rainfall&nbsp;Last&nbsp;24&nbsp;Hours</td>
    <td><span id="cmx-r24hour"></span>&nbsp;<span class="cmx-rainunit"></span></td>
  </tr>

  <tr>
    <td colspan="4" class="tableseparator_wind">Wind</td>
  </tr>
  <tr class="td_wind_data">
    <td>Wind&nbsp;Speed&nbsp;(gust)</td>
    <td><span id="cmx-wgust"></span>&nbsp;<span class="cmx-windunit"></span></td>
    <td>Wind&nbsp;Speed&nbsp;(avg)</td>
    <td><span id="cmx-wspeed"></span>&nbsp;<span class="cmx-windunit"></span></td>
  </tr>
  <tr class="td_wind_data">
    <td>Wind Bearing</td>
    <td><span id="cmx-avgbearing"></span>&deg; <span id="cmx-wdir"></span></td>
    <td>Beaufort&nbsp;<span id="cmx-beaufort"></span></td>
    <td><span id="cmx-beaudesc"></span></td>
  </tr>
  <tr class="td_wind_data">
    <td>Wind Variation (last 10 minutes)</td>
    <td>From&nbsp;<span id="cmx-BearingRangeFrom"></span>&deg;&nbsp;To&nbsp;<span id="cmx-BearingRangeTo"></span>&deg;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4" class="tableseparator_pressure">Pressure</td>
  </tr>
  <tr class="td_pressure_data">
    <td>Barometer&nbsp;</td>
    <td><span id="cmx-press"></span>&nbsp;<span class="cmx-pressunit"></span></td>
    <td><span id="cmx-presstrend"></span></td>
    <td><span id="cmx-presstrendval"></span>&nbsp;<span class="cmx-pressunit"></span>/hr</td>
  </tr>
</table>
<div class="td_navigation_bar">
  :<a href="index.htm">now</a>:<wbr>:<a href="gauges.htm">gauges</a>:<wbr>:<a href="today.htm">today</a>:<wbr>:<a href="yesterday.htm">yesterday</a>:<wbr>:<a href="thismonth.htm">this&nbsp;month</a>:<wbr>:<a href="thisyear.htm">this&nbsp;year</a>:<wbr>:<a href="record.htm">records</a>:<wbr>:<a href="monthlyrecord.htm">monthly&nbsp;records</a>:<wbr>:<a href="trends.htm">trends</a>:<wbr>:<a href="selectachart.htm">selectachart</a>:<wbr>:<a href="historic.htm">historic</a>:<wbr><span id="cmx-forum"></span><wbr><span id="cmx-webcam"></span>
</div>
<p class="credits"><br />
  Page updated <span id="cmx-update"></span><br />
  powered by <a href="https://cumuluswiki.wxforum.net/a/Software" target="_blank">Cumulus</a> v<span id="cmx-version"></span> (<span id="cmx-build"></span>)
</p>
</div>
  <!-- Google CDN hosted JQuery library -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  <!-- or... -->
  <!-- Local JQuery library, do not use if your containing page already pulls in a copy of JQuery -->
  <!-- <script src="scripts/jquery-1.8.2.min.js"></script> -->
  <script src="js/setpagedata.js"></script>
</body>
</html>
Uses

Code: Select all

  <tr class="td_temperature_data">
    <td>Temperature</td>
    <td><span id="cmx-temp"></span>&nbsp;<span class="cmx-tempunit"></span></td>
    <td>Dew&nbsp;Point </td>
    <td><span id="cmx-dew"></span>&nbsp;<span class="cmx-tempunit"></span></td>
  </tr>
etc, etc...

Re: .htaccess for Test Site Data.

Posted: Wed 26 May 2021 1:46 pm
by mcrossley
OK, with you now.

It appears that data driven legacy site has fallen victim to changes made to the new site. :(

The legacy in the zip uses a different schema to identify the data fields than is now used.

For instance in index.htm the dawn time...

Legacy =

Code: Select all

<span id="cmx-dawn"></span>
New =

Code: Select all

<span data-cmxdata="dawn"></span>
It would need all the id's (and classes for common things like units) changing over to use the new schema of data-cmxdata attributes.

Re: .htaccess for Test Site Data.

Posted: Wed 26 May 2021 2:19 pm
by mcrossley
Here is a quick global search and replace - it should have fixed the legacy pages, but I haven't tested it :shock:

Edit: see later post...

Re: .htaccess for Test Site Data.

Posted: Wed 26 May 2021 8:29 pm
by Phil23
Thanks Mark,

That's an improvement.
The basic pages all have data now, but there must be something missing from the JS as the Trends page has not Lat/Long
& Gauges still dont work.

There is a formatting issue also regards the Degree symbol is given places;
Not working for temp, but ok on Wind Dir.

Re: .htaccess for Test Site Data.

Posted: Wed 26 May 2021 8:33 pm
by mcrossley
See my post a few up re not updating websitedataT.json

Re: .htaccess for Test Site Data.

Posted: Wed 26 May 2021 9:05 pm
by Phil23
Just read that & fixed the websitedataT.json

Still no data in Gauges, and no header & footer data in both Graphs & Trends.

Fixed & then broke it again with a hard refresh,
Then Fixed it again....

Looks like the Zip you posed has an old setpagedata.js which I uploaded along with the rest of the zip contents.
Replaced it with the current setpagedata.js & that brought it back again.

Did notice yesterday that the content of the legacy Zip varied in date from the current releases,
Presumed at least some need to be the same.

Phil.

Edit still have the URL issue at the bottom of http://weather.inverellit.com/legacy/

Re: .htaccess for Test Site Data.

Posted: Thu 27 May 2021 8:59 am
by mcrossley
I'm surprised the new web site version of setpagedata.js worked at all with the legacy site!

Anyway updated version of the script attached.