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

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

    I've added a Wordpress blog to my ZC site, in a /blog folder, which is working fine.
    I've moved some of my EZ-pages to the blog, since they don't really belong on the home page.

    Some of these pages were getting google traffic, which I'm trying to redirect (301) to the blog page, but I can't get this working. I'm trying to do this in .htaccess as follows:

    Redirect 301 /index.php?main_page=page&id=25 /blog/table-tennis-rules/
    I've tried the above, I've also tried to redirect to the full domain, or without the trailing "/", but it never works properly. Problem is:

    - when it does redirect, it does a 302 instead of a 301
    - it seems to re-direct multiple (other) EZ-pages also to the same destination
    - it adds a trailing "main_page=page&id=25" to the end of the destination URL

    I suspect it's getting screwed up with some of the characters in the source domain, or perhaps it does not like being redirected to what looks like a folder in stead of a file. I can't figure it out!

    Can someone advise me how to do this please, it would be a great help!

    Thanks a lot!

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

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

    First would be not yet to do a 301 but instead a 302 until the solution is satisfactorily found. This prevents a browser from caching the redirect as permanent instead of temporary.

    Next is to identify what all is in your htaccess including the current sequence of the commands.

    In the interim you may want to be sure that you are clearing your cache (and maybe cookies) on the browser that you're using between attempts at least.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,685
    Plugin Contributions
    9

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

    Quote Originally Posted by mc12345678 View Post
    First would be not yet to do a 301 but instead a 302 until the solution is satisfactorily found. This prevents a browser from caching the redirect as permanent instead of temporary.

    Next is to identify what all is in your htaccess including the current sequence of the commands.

    In the interim you may want to be sure that you are clearing your cache (and maybe cookies) on the browser that you're using between attempts at least.
    hey mate,
    i'm going to take you up on that beer when down under!

    @mc,
    #1 - i do not think the doing a 302 here is at all necessary. the op has stated that they are already getting a 302, so not sure what is the point of changing the htaccess rule.

    #2 - as mc has stated, i would post the complete contents of you .htaccess file. i am NOT the apache redirect expert, but it looks to be 1 of 2 choices, a.) there is another rule that is redirecting prior to hitting your rule. b.) your redirect rule is not working/getting ignored because it is not properly constructed or the .htaccess is in the wrong place. i'm betting with option b. my reasoning is simple... if one were to go to your site, the redirect is the same for both of these URLs:

    /index.php?main_page=page&id=25
    /index.php?main_page=page&id=2545665

    which indicates to me the redirect is happening with ZC and not with your htaccess rule.

    #3 - definitely not a browser cache/cookie problem.

    good luck.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  4. #4
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

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

    You could also edit the /includes/modules/pages/page/header_php.php and add some PHP code to do the redirect.

    Something akin to this human-language description:
    if (the page number is 25) {
    ... run the PHP statement: header('Location: /blog/whatever-page-name');
    }
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

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

    As for the redirect "issue" of the parameter remaining in the new/redirected url, the htaccess command "Redirect" does not strip the parameter from the url. Therefore to remove it via htaccess, would be better to use "RewriteRule" which also can be written to only redirect id=25 and not include any other page that starts with 25.

    Code:
    RewriteRule ^index\.php?main_page=page&id=25$ /blog/table-tennis-rules? [L, R=301]
    As to temporarily using 302 versus 301, imagine this. An attempt to redirect is entered. A customer goes to the original address. The attempt fails because it was wrong. The customer's browser has been told that the address attempted has been permanently moved to some other non-existent location via cache. How do you tell them to clear their cache? Did your heaers include anything that would pull a new reference/location after some set time out? Does their browser support such a request?

    All because wanted to test something...

    It's akin to testing that the SSL certificate has been properly installed before changing a site to https and then finding out that it wasn't properly installed and shouldn't have been activated (yet). Why do something as a self test that has to be undone by others when it is possible to temporarily test and then when successful, "lock" it in.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

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

    Thanks for your time guys, really appreciate it!
    Quote Originally Posted by mc12345678 View Post
    Code:
    RewriteRule ^index\.php?main_page=page&id=25$ /blog/table-tennis-rules? [L, R=301]
    That causes an internal server error.
    Here is the rest of my .htaccess
    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^tibhar\.com\.au$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.tibhar\.com\.au$
    RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
    RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^/?$ "http\:\/\/tabletennisshop\.com\.au\/index\.php\?main_page\=page\&id\=44" [R=301,L]
    RewriteCond %{HTTP_HOST} ^xiom\.com\.au$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.xiom\.com\.au$
    RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
    RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^/?$ "http\:\/\/tabletennisshop\.com\.au\/index\.php\?main_page\=page\&id\=51" [R=301,L]
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    The existing code refers to two domains (xiom and tibhar) being redirected to a specific page on the site (done through cpanel, looks messy I know), and the last bit redirects http to https.

  7. #7
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

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

    So where in that htaccess was the RewriteRule inserted/tested?

    Would advise that since it appears (haven't fully inspected the provided htaccess) desirable to have all domains use https that the RewriteRules direct to https: instead of http: so that there are fewer redirects when accessing that/those uris.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

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

    I've tried inserting it at the top, and at the bottom, results are the same.

    Yes you're right about the other re-directions, they should go right to https. I'm a bit nervous to touch them as they're currently working, and I know very little about this stuff.

  9. #9
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,685
    Plugin Contributions
    9

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

    @ttfan,
    i am NOT good at apache redirects. but i am willing to try.

    that said, i do not agree with some of the logic going on in this thread. while this could be accomplished from within the ZC core, i am not a fan of doing it that way as it creates more work at upgrade time.

    with regards to your htaccess, i would remove the 2nd instance of:

    Code:
    RewriteEngine On
    there is no need for it.

    in addition, there are 2 problems (that i can see) with regards to mc's rewrite rule. when i tested it, i was also able to reproduce the internal server error. assuming our servers are similarly configured, i think the space in-between the L and the R=301 is what is causing that error. if you remove that space (similar to your other htaccess directives that are working), then the internal server error disappears.

    please test that for yourself.

    the second problem with that rewrite rule is it does not work. there is something going on with the parameters section of the requesting url that prevents it from matching the rule. i'm still trying to figure it out for myself.

    this is a good tool here:

    http://htaccess.mwl.be/

    i'll keep you posted if i figure anything else out.

    best.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  10. #10
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,685
    Plugin Contributions
    9

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

    try this after rewrite engine on:

    Code:
    RewriteCond %{QUERY_STRING} main_page=page&id=25
    RewriteRule ^index\.php$ /blog/table-tennis-rules? [L,R=301]
    best.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

 

 
Page 1 of 2 12 LastLast

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