Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2014
    Location
    London
    Posts
    22
    Plugin Contributions
    0

    Default htaccess redirect from old subdirectory site to new subdomain site

    hello

    I have an old version of zencart (1.3.8) in a subdirectory. The site is live: www.mydomain.com/zencart

    I have recently upgraded to 1.5.1 successfully and installed CEON URI mapping on the 1.5.1 test site in a subdomain : www.shop.mydomain.com and have uri mapped all the categories and products

    mydomain.com included some .shtml files which I now have put up as ezpages on shop.mydomain.com

    I want to redirect the old pages on mydomain.com/zencart to their equivalent pages in shop.mydomain.com. Eventually when testing is over I will move shop.mydomain.com to mydomain.com

    I've tried to redirect a couple of the old pages (which are still live) to see if it works, but I haven't managed to. I've included the following in the .htaccess of the root (mydomain.com/zencart)

    Code:
    RewriteEngine On 
    //301 Redirect Old File
    Redirect 301 /zencart/index.php?main_page=product_info&cPath=3_23&products_id=27 http://www.shop.mydomain.com/category-fruit/subcategory-apples/redapples?cPath=3_23&
    
    RedirectMatch 301 /zencart/index.php?main_page=index&cPath=3_23(.*)  http://www.shop.mydomain.com/category-fruit/subcategory-apples/$1
    None of this worked and I still get mydomain.com/zencart rather than shop.mydomain.com

    (Path 3 is category-fruit and path 23 is subcategory-apples, red apples are product 27 in the old version at mydomain.com/zencart). I kept the same categories/subcategories and products numbers on the new subdomain version shop.mydomain.com but now these have uri mapping. I'd like to be able to redirect the old unfriendly urls to the new uri mapped ones. I also have to redirect the old .shtml files to the ezpages. Also I'd like to prepare an .htaccess file for when I transfer from shop.mydomain.com to mydomain.com

    Can anyone help to point me in the right direction please?

    thanks
    Millie
    Last edited by Millie63; 28 May 2014 at 12:02 PM. Reason: code tags

  2. #2
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default Re: htaccess redirect from old subdirectory site to new subdomain site

    "Redirect" (mod_alias) only matches on URL path. If you need to match "Query Terms", use "RewriteCond" and "RewriteRule" (mod_rewrite) instead.

    Most of the working "URI Mapping" tools will automatically handle requests for previously configured URLs as well as stock Zen Cart URLs (and set the canonical to the new URL). Some "URI Mapping" tools contain a feature to additionally issue an automatic 301 redirect (when enabled).

    If as part of your upgrade you performed a "database upgrade", the database IDs for each product and category should be the same. The previous post seems to confirm these are the same. This means you most likely do not need to create manual redirects (3xx).

    Now some questions which need to be answered:
    Are you ready to migrate from the old store to the new store?
    Why not just move the new store directly onto "mydomain.com" (when ready)?
    Why not just let the "URI Mapping" tool handle the previous URLs (shtml -> ez-pages)?
    Why not use a simple RewriteRule (no redirect) to handle the path (folder) change?
    The glass is not half full. The glass is not half empty. The glass is simply too big!
    Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
    Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

  3. #3
    Join Date
    Apr 2014
    Location
    London
    Posts
    22
    Plugin Contributions
    0

    Default Re: htaccess redirect from old subdirectory site to new subdomain site

    Quote Originally Posted by lhungil View Post
    "Redirect" (mod_alias) only matches on URL path. If you need to match "Query Terms", use "RewriteCond" and "RewriteRule" (mod_rewrite) instead.

    Most of the working "URI Mapping" tools will automatically handle requests for previously configured URLs as well as stock Zen Cart URLs (and set the canonical to the new URL). Some "URI Mapping" tools contain a feature to additionally issue an automatic 301 redirect (when enabled).

    If as part of your upgrade you performed a "database upgrade", the database IDs for each product and category should be the same. The previous post seems to confirm these are the same. This means you most likely do not need to create manual redirects (3xx).

    Now some questions which need to be answered:
    Are you ready to migrate from the old store to the new store?
    Why not just move the new store directly onto "mydomain.com" (when ready)?
    Why not just let the "URI Mapping" tool handle the previous URLs (shtml -> ez-pages)?
    Why not use a simple RewriteRule (no redirect) to handle the path (folder) change?
    Hi lhungil

    Thank you so much for your answer.
    I'm still tryng to understand how .htaccess works and the whole redirection/rewriting thingie. I'm quite baffled by all of it to be honest so please bear with me and my ignorance :)

    I did a database upgrade with the new store.

    To answer yr questions:

    Are you ready to migrate from the old store to the new store?
    Not quite ready yet, but almost there.

    Why not just move the new store directly onto "mydomain.com" (when ready)?
    That's the plan. I just didn't want to take down the old site while preparing the new store in order not to lose customers. If people have linked to the site with the old unfriendly urls, don't I have to redirect them to the new uri-mapped ones? Or would this be done automatically?

    Why not just let the "URI Mapping" tool handle the previous URLs (shtml -> ez-pages)?
    The old .shtml pages were not part of the zencart before so I'm not too sure how the URI mapping tool could handle them. Do you mean naming the pages with the old .shtml names and then optimising these in the uri mapping tool? The old .shtml names are really not optimised and I'd like to optimise then because these are the pages that get most visitors to the site. Incidentally I've noticed that there's no place in ezpages where I can put manipulate the Title tag, meta keywords and descriptions. Is there a plugin for this?

    Why not use a simple RewriteRule (no redirect) to handle the path (folder) change?
    This would be good to do. I should also add that the site mydomain.com is an addon domain on cpanel. Does this mean that I leave everything in shop.mydomain.com and just include a RewriteRule in the htaccess of /public_html? I'd rather have the whole cart in its own addon domain folder in order to avoid confusion. Do you think this is wise? If it is, the .htaccess should be in the root of the addon folder mydomain.com, is that right?

    Would this be correct if I put it in htaccess of addon domain folder?
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/zencart/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /$1

    I'd be grateful if you can correct this pls.

    Thanks a million for your help.
    (and I agree - the glass is really too big :)
    Millie
    Last edited by Millie63; 29 May 2014 at 12:00 PM.

  4. #4
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default Re: htaccess redirect from old subdirectory site to new subdomain site

    Quote Originally Posted by Millie63 View Post
    ...
    Are you ready to migrate from the old store to the new store?
    Not quite ready yet, but almost there.

    Why not just move the new store directly onto "mydomain.com" (when ready)?
    That's the plan. I just didn't want to take down the old site while preparing the new store in order not to lose customers. If people have linked to the site with the old unfriendly urls, don't I have to redirect them to the new uri-mapped ones? Or would this be done automatically?
    ...
    Zen Cart is based upon what is known as the "front controller" design pattern. This essentially means all requests for a page go to a single "entry" point and then the software determines which page to show based upon the request. Most of the "human friendly" URL generation tools (including CEON URL) hook into this entry point and add additional interpretation to accommodate the requests for "human friendly" URLs.

    This means most of the tools do not require the end user to manually redirect requests for "stock" Zen Cart URLs. The "human friendly" URL tool simply handles the "human friendly" requests and modifies the request environment to supply the needed information. So requests to the following appear the same to Zen Cart's internal code:
    Code:
    /zencart/index.php?main_page=index&cPath=3_23
    /zencart/category-fruit/subcategory-apples/
    Quote Originally Posted by Millie63 View Post
    ...
    Why not just let the "URI Mapping" tool handle the previous URLs (shtml -> ez-pages)?
    The old .shtml pages were not part of the zencart before so I'm not too sure how the URI mapping tool could handle them. Do you mean naming the pages with the old .shtml names and then optimising these in the uri mapping tool?...
    "CEON URI Mapping" keeps a "history" of URLs for each "page". This means all one really needs to do is first configure (and save) the original URL (.shtml). Then one configures and save the new (desired) URL. Both alternative URIs (and the stock Zen Cart URI) are handled automatically. Most of this is covered in more detail in the README file which accompanies "CEON URI Mapping".

    Quote Originally Posted by Millie63 View Post
    ...
    Why not use a simple RewriteRule (no redirect) to handle the path (folder) change?
    This would be good to do. I should also add that the site mydomain.com is an addon domain on cpanel. Does this mean that I leave everything in shop.mydomain.com and just include a RewriteRule in the htaccess of /public_html? I'd rather have the whole cart in its own addon domain folder in order to avoid confusion. Do you think this is wise? If it is, the .htaccess should be in the root of the addon folder mydomain.com, is that right?
    mapping tool?...
    The question I would ask is "What business purpose is served by having your main website and the store on a different domain?".

    Generally I would recommend the store and the main website (especially if they share a template) being located in the same domain. This makes it obvious to customers and search engines only one company is involved. This also makes it easier to incorporate portions of Zen Cart into other pages on the site (and vice versa).

    There is one minor change one may need to make to the .htaccess file generated by CEON URI if non Zen Cart "pages" or "software" share the same domain... But the change varies by software, paths, etc... But rest assured it is a minor and easy change.

    Quote Originally Posted by Millie63 View Post
    ... Would this be correct if I put it in htaccess of addon domain folder? ...
    I'd probably just modify the Request URI and let "CEON URI Mapping" handle the canonical (and redirect if enabled).

    Assuming the store will be placed on the same domain as the original store:
    Code:
    ###############################################################################
    # Enable mod_rewrite processing using the rules in this .htaccess file
    ###############################################################################
    # Notes: 
    #
    # For mod_rewrite to work, the Apache server option to allow symbolic links to
    # be followed must be enabled. Most providers supporting mod_rewrite will
    # already have it enabled for you, but if your rewrite rules are not working
    # you can un-comment the first directive below to manually enable the option.
    #
    # Don't forget, mod_rewrite directives are processed in order until a matching
    # RewriteRule with the [L] flag is encountered. So the more specific a rule is
    # the closer it should appear to the top of this file.
    #
    # These directives should only appear once in the .htaccess file
    ###############################################################################
    #Options +FollowSymLinks
    RewriteEngine on
    
    ###############################################################################
    # Remove "/zencart" if present from the request URI
    ###############################################################################
    # Notes:
    #
    # These directives should proceed rules added by CEON URI Mapping
    ###############################################################################
    RewriteCond %{REQUEST_URI} ^/?zencart/
    RewriteRule ^(/?)zencart/(.*)$ $1$2
    Otherwise much will depend upon how exactly the "main" and "addon" domains are located and configured by the hosting provider. One may be able to apply something similar to the above, or may be forced to add the new domain name and the flags [R=301, L].

    Quote Originally Posted by Millie63 View Post
    ... Incidentally I've noticed that there's no place in ezpages where I can put manipulate the Title tag, meta keywords and descriptions. Is there a plugin for this? ..
    A quick search finds: Can I set meta tags on EZ Pages? There have been discussions about some other ways to accomplish the same result without adding a plugin. However there is also a plugin for Zen Cart 1.5.0 called EZ-Pages Meta Tag Fields (I have not personally used this, but it may fit your needs).

    Further discussion of the topic of meta tags / ez-pages would best be done in a new topic.

    Note: An easy way to search a specific site using Bing or Google is using the "site:" option. For example: "my search terms site:zen-cart.com". This is what I typically use to search the Zen Cart forums, plugins, faqs, and wiki all at once.
    Last edited by lhungil; 29 May 2014 at 05:33 PM.
    The glass is not half full. The glass is not half empty. The glass is simply too big!
    Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
    Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

  5. #5
    Join Date
    Apr 2014
    Location
    London
    Posts
    22
    Plugin Contributions
    0

    Default Re: htaccess redirect from old subdirectory site to new subdomain site

    hi again lhungil

    Thanks for replying in so much detail. Greatly appreciated. I'm still trying to digest it all (while trying to pretend I know what I'm doing - what a joke! if pigs could fly etc etc.)

    I think I need to explain the structure of what's on my cpanel. Basically it's got 3 different websites on it - they don't have anything to do with each other. Two are different small business websites and one is an art showcase.

    The primary domain (ecl.com) is a small business website - mainly a static website with 5 info pages, another 4 pages with quizzes and a contact form. The plan is to change this over to a wordpress site eventually.

    The art showcase is an addon domain in folder /artwebsite.com in /public_html

    The website with the zencart is another addon domain (/mydomain.com in /public_html). This is the biggest website of the 3.
    The old (and still active) site format is
    www.mydomain.com/what-are-now-ezpages.shtml (about 15 pages of these)
    and
    www.mydomain.com/zencart
    The test website is the folder /shop in public_html and it is installed as a subdomain (shop.mydomain.com).
    If I understood correctly I do not need to do any redirection when I finally move shop.mydomain.com to mydomain.com (except for the following:-
    RewriteCond %{REQUEST_URI} ^/?zencart/
    RewriteRule ^(/?)zencart/(.*)$ $1$2
    which should come before the CEON uri mapping code in .htaccess in mydomain.com

    I was told by my hosting company that I can have different websites on same cpanel. When I did site:domain.com searches for all three, only pages from one domain show up and there's no crossing over. In awstats however, both addon domains show as subdomains of the primary domain - but I guess this doesn't matter much as only I see the awstats. I hope having 3 sites on same cpanel is not effecting SEO for the addon domains - or the primary domain for that matter. Any thoughts on this? I read somewhere that I should probably have [R301] redirects for both the addon domains to redirect subdomain.primarydomain.com to domain.com (i.e artwebsite.ecl.com to artwebsite.com) for SEO reasons. What's your take on this?

    Oh and I've installed the EZpages meta tag fields plugin on the test site. Thank you :)

    Now I need a break coz I'm seeing double About to make that half full /empty glass into 1/4 : 3/4
    Cheers!

  6. #6
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default Re: htaccess redirect from old subdirectory site to new subdomain site

    Quote Originally Posted by Millie63 View Post
    ... In awstats however, both addon domains show as subdomains of the primary domain - but I guess this doesn't matter much as only I see the awstats. ... I read somewhere that I should probably have [R301] redirects for both the addon domains to redirect subdomain.primarydomain.com to domain.com (i.e artwebsite.ecl.com to artwebsite.com) for SEO reasons. What's your take on this?
    ...
    Unless another.domain.tld is linked to, most SEs will never see another.domain.tld (only the add-on domain's name). But to be on the safe side one could redirect all requests to a specific FQDN (Fully Qualified Domain Name). Keep in mind Zen Cart will only generate links using the defined values of HTTP_SERVER and HTTPS_SERVER (which should contain the desired FQDNs).

    Code:
    ###############################################################################
    # Enable mod_rewrite processing using the rules in this .htaccess file
    ###############################################################################
    # Notes: 
    #
    # For mod_rewrite to work, the Apache server option to allow symbolic links to
    # be followed must be enabled. Most providers supporting mod_rewrite will
    # already have it enabled for you, but if your rewrite rules are not working
    # you can un-comment the first directive below to manually enable the option.
    #
    # Don't forget, mod_rewrite directives are processed in order until a matching
    # RewriteRule with the [L] flag is encountered. So the more specific a rule is
    # the closer it should appear to the top of this file.
    #
    # These directives should only appear once in the .htaccess file
    ###############################################################################
    #Options +FollowSymLinks
    RewriteEngine on
    
    ###############################################################################
    # Redirect to the desired FQDN if the request was not for the desired FQDN
    ###############################################################################
    # Notes: 
    #
    # This utilizes a HTTP/301 response. Any POST data will be discarded. 
    ###############################################################################
    RewriteCond %{HTTP_HOST} !host\.domain\.tld$ [NC]
    RewriteRule ^.*$ http://host.domain.tld%{REQUEST_URI} [R=301,QSA,L]
    
    ###############################################################################
    # Remove "zencart" if present from the request URI
    ###############################################################################
    # Notes:
    #
    # Some servers add a leading slash "/" and others do not. This rule attempts
    # to handle both, but one may need to alter this by hand on some servers.
    ###############################################################################
    RewriteCond %{REQUEST_URI} ^/?zencart/
    RewriteRule ^(/?)zencart/(.*)$ $1$2
    
    ###############################################################################
    # CEON URI Mapping
    ###############################################################################
    Last edited by lhungil; 29 May 2014 at 10:37 PM.
    The glass is not half full. The glass is not half empty. The glass is simply too big!
    Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
    Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

 

 

Similar Threads

  1. v151 Need to redirect from old site links (including search engine links) too new site
    By swdynamic in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 15 Jun 2015, 04:40 AM
  2. What do I need in .htaccess to redirect to my new site?
    By marvin in forum Installing on a Linux/Unix Server
    Replies: 4
    Last Post: 18 Mar 2013, 09:01 PM
  3. Redirect From Old Site To New Site
    By devlin in forum General Questions
    Replies: 4
    Last Post: 14 Mar 2012, 01:25 PM
  4. v150 Redirect from old osc site to new zc site?
    By DIHI in forum General Questions
    Replies: 2
    Last Post: 2 Feb 2012, 05:42 PM

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