Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13
  1. #11
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    231
    Plugin Contributions
    0

    Default Re: Trouble redirecting EZ-page to blog page via .htacess

    Seems to work well, thank you again!

    The only minor issue was that pages of ID 25, or 255 or anything else starting with 25 re-directs to the same page. This was fixed with a $ after the 25.

    I've also removed the extra "rewrite engine on", and have my domains now going straight to htpps.

    Thanks a lot guys!!! The beers are waiting.

  2. #12
    Join Date
    Jul 2012
    Posts
    16,798
    Plugin Contributions
    17

    Default Re: Trouble redirecting EZ-page to blog page via .htacess

    One problem with adding the $ at the end of that one parameter is that if there is a link "saved" or accessed that perhaps contains a zenId or has some other parameter on the uri, then a redirect will not occur (strengthening DrByte's recommendation to internally perform the redirect instead of trying to review/validate any possible combination of URIs that might be seen); however, in attempt to account for such on the URI and using an htaccess, might I suggest the following modification/use:
    Code:
    RewriteCond %{QUERY_STRING} ^(main_page=page&(.*)$|(.*)&main_page=page&(.*)$|(.*)&main_page=page$) [NC]
    RewriteCond %{QUERY_STRING} ^(id=52&(.*)$|(.*)&id=52&(.*)$|(.*)&id=52$) [NC]
    RewriteRule ^index\.php(.*) /blog/fun-run? [L,R=301]
    What this does is support the main_page parameter being at the front, middle or end of the QUERY_STRING *AND* the id being at the front, middle or end (obviously both can not be at the front nor both at the end) of the string. Problem with this also is if say the id parameter is on the uri more than once:
    Code:
    index.php?main_page=page&id=2&id=52
    Then it will still redirect (id=52 is present) even though if using the ZC "redirect", ZC would evaluate the uri as being applicable to id=2 and would not redirect...

    To provide a solution that does not require modification of the existing code and therefore a need to be modified in a rebuilt store (but would require copying over to a new installation) the following could be used:

    a new file to be loaded into or created in

    includes/classes/observers

    with the filename possibly:

    auto.redirect_specific_ez_pages.php

    that has the following content:
    Code:
    <?php
    /**
     * This redirects the designated ez-Pages to the chosen location
     * @copyright mc12345678 2018 https://mc12345678.com
     * @version applicable to ZC 1.5.3 and later.  Earlier requires an includes/auto_loaders config.xxx file to invoke this auto.redirect_specific_ez_pages.php file as an observer class
     **/
    
    class zcObserverRedirectSpecificEzPages extends base {
             function __construct() {
                $attachThis = array();
    
                $attachThis[] = 'NOTIFY_HEADER_START_EZPAGE';
    
                $this->attach($this, $attachThis);
            }
    
           /**
             * Camelized Notifier that is available in ZC 1.5.3 and above and is called when notifier NOTIFY_HEADER_START_EZPAGE is encountered.
             * @parameter &$callingClass this modifiable variable provides access to the class that initiated the request.
             * @parameter $notifier this contains the string of the name of the notifier that led to executing this function.
             **/
            function updateNotifyHeaderStartEzPage(&$callingClass, $notifier) {
                   if (isset($_GET['page']) && (int)$_GET['page'] == 25) {
                          // Redirects to the identified location, replacing previous headers that may have been sent, using a 301 redirect code
                          header('Location: /blog/table-tennis-rules/', true, 301);
                   }
            }
    
            /**
             * This is the generic observer function that is called if a camelized version of the attached notifier is not found.  In versions of ZC pre-1.5.3, this is the
             *   function that is called for all observers.  It is possible in version before ZC 1.5.3 to also receive a non-editable "array" of data.  Non-editable meaning
             *   that changes made here are not carried back to where the notifier is present.  The notifier identified here does not pass any additional data and also
             *   by ZC design is in the global scope of the code, therefore to modify anything presented in the header file, that variable could be made global here
             *   and its results would be passed back to the line "after" the invoking notifier.
             * @parameter &$callingClass this modifiable variable provides access to the class that initiated the request.
             * @parameter $notifier this contains the string of the name of the notifier that led to executing this function.
             **/
            function update(&$callingClass, $notifier) {
                if ($notifier === 'NOTIFY_HEADER_START_EZPAGE') {
                    // Calls the internal class function that handles the request.  This way the code is written in one place and changes can be made that are applicable
                    //   to all versions of ZC in which this is ultimately executed.
                    $this->updateNotifyHeaderStartEzPage($callingClass, $notifier);
                }
            }
     }
    Last edited by mc12345678; 9 Jan 2018 at 01:55 PM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #13
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    231
    Plugin Contributions
    0

    Default Re: Trouble redirecting EZ-page to blog page via .htacess

    Thank you very much MC!

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 2
    Last Post: 15 Aug 2011, 08:59 PM
  2. Wordpress Blog Summary on Zen Cart Homepage via 'Main Page'
    By rogg in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 13 Jan 2011, 01:22 AM
  3. trouble redirecting navigation links to an html index
    By boplinger in forum General Questions
    Replies: 3
    Last Post: 24 Nov 2009, 03:24 AM
  4. Embedding ZC In a Blog Page??
    By gabstero in forum General Questions
    Replies: 7
    Last Post: 16 Apr 2009, 06:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR