Jump to content

get input not being picked up on front page?


Ivo
 Share

Recommended Posts

Hi Folks,

 

my input string which I wish ot place into Snipcart's cart object doesnt work on the homepage url (site is HTTPS)

https://ancientlakesmagnesium.com.au/?id=1297&src=facebook

 

The query string works on the sub pages though?

My code is as follows..

<?php
if($input->get->id) {
        $affID = $input->get->id;
$affiliateId = $pages->get("template=affiliate,id=$affID, include=hidden");
    
if($affiliateId != '') {
    $linkaff= $input->get->src;
  echo "<script> 

  Snipcart.subscribe('cart.ready', function() {
  Snipcart.api.cart.start()
    .then(function (cart) {
         Snipcart.api.cart.metadata({
    'trackingID': '{$affiliateId->title}',
    'trackingSrc': '{$linkaff}',
    'trackingLandingPage': '{$page->httpUrl}',
    'trackingReferrer': '{$_SERVER['HTTP_REFERER']}'
});
        console.log (cart);
    });

});


  </script>";

}
}

  ?>

The site is on IIS and the Web host created a web.config file as follows

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

<system.webServer>

<directoryBrowse enabled="false" />

<rewrite>

    <rules>
                <clear />
                <rule name="Remove WWW" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
                    </conditions>
                    <action type="Redirect" url="http://ancientlakesmagnesium.com.au{PATH_INFO}" />
                </rule>
                <rule name="Redirect to HTTPS" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
                </rule>
                <rule name="Handle request for missing favicon.ico" stopProcessing="true">
                    <match url="favicon\.ico" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="CustomResponse" statusCode="404" subStatusCode="1" statusReason="The requested file favicon.ico was not found" statusDescription="The requested file favicon.ico was not found" />
                </rule>
                <rule name="Handle request for missing robots.txt" stopProcessing="true">
                    <match url="robots\.txt" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="CustomResponse" statusCode="404" subStatusCode="1" statusReason="The requested file robots.txt was not found" statusDescription="The requested file robots.txt was not found" />
                </rule>
                <rule name="Access Restrictions: Keep web users out of directories">
                    <match url="(^|/)\." ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="Access Restrictions: Protect ProcessWire system files" stopProcessing="true">
                    <match url="^.*$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
                        <add input="{URL}" pattern="(^|/)site/assets/(cache|logs|backups|sessions|config|install)($|/.*$)" ignoreCase="false" />
                        <add input="{URL}" pattern="(^|/)site/install($|/.*$)" ignoreCase="false" />
                        <add input="{URL}" pattern="(^|/)site/config\.php$" ignoreCase="false" />
                        <add input="{URL}" pattern="(^|/)(wire|site)/templates-admin($|/|/.*\.(php|html?|tpl|inc))$" ignoreCase="false" />
                        <add input="{URL}" pattern="(^|/)site/templates($|/|/.*\.(php|html?|tpl|inc))$" ignoreCase="false" />
                        <add input="{URL}" pattern="(^|/)site/assets($|/|/.*\.php)$" ignoreCase="false" />
                        <add input="{URL}" pattern="(^|/)wire/(core|modules)/.*\.(php|inc|tpl|module)$" ignoreCase="false" />
                        <add input="{URL}" pattern="(^|/)site/modules/.*\.(php|inc|tpl|module)$" ignoreCase="false" />
                        <add input="{URL}" pattern="(^|/)(COPYRIGHT|INSTALL|README|htaccess)\.txt$" ignoreCase="false" />
                        <add input="{URL}" pattern="(^|/)site-default/" ignoreCase="false" />
                    </conditions>
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="ProcessWire Rewrite" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{URL}" pattern="^/~?[-_.a-zA-Z0-9/]*$" ignoreCase="false" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" pattern="(favicon\.ico|robots\.txt)" ignoreCase="false" negate="true" />
                        <add input="{URL}" pattern="\.(gif|jpg|png|ico)$" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php?it={R:1}" appendQueryString="true" />
                </rule>


    </rules>

</rewrite>


        <httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL">
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" path="/index.php" responseMode="ExecuteURL" />
        </httpErrors>


        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
            </files>
        </defaultDocument>


</system.webServer>

</configuration>

The code seems to work on local host WAMP (on http not https) on the front page, does anyone know if its the web.config file that's stopp PW seeing the input query string?

 

Thanks,

Ivo

 

Link to comment
Share on other sites

Since the ProcessWire Rewrite rule has appendQueryString set to true in your web.config, this should work. Is the main page using a different php template that lacks the necessary includes perhaps?

Link to comment
Share on other sites

It should work. I'm using an identical rule in web.config for multiple sites, and passing query parameters to PW's root url works fine. Did you try to output $input->get->id to see if it's populated?

Link to comment
Share on other sites

Hi BitPoet,

 

I tried to output $input->get->id but nothing populated on the live site, but works on my localhost (which uses .htaccess as opposed to web.config on the live site).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...