Announcement

Collapse
No announcement yet.

URI Management not redirecting Long URLs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    URI Management not redirecting Long URLs

    I am trying to transition from Long URLs (/store/merchant.mvc?Screen=PROD&Product_Code=123) that my store was originally set up with to URI Management using slugified page titles (/slugified-product-name.html). I have successfully switched the Link Source to URI Management and the new slugified URIs are mostly working, but the 301 redirects I created from my old URLs are not redirecting to the new slugified URIs.

    I have read everything I can find on URI Management on miva's site and the forums. One thing that pretty much every page says is that if you're changing your URL structure (which I am), to maintain search engine rankings you need to be sure to also create URIs based on your old URLs that search engines already know about and set them up as 301 redirects to your new canonical URIs. As far as I can tell I've done this. However, if I enter one of my old URLs in the browser manually, the site pulls up the page correctly, but retains the old style URL in the address bar. (The .htaccess Status in URI Management says I'm up to date.)

    One forum post in particular (attached) seems to suggest that you cannot have question marks in URIs but I haven't read this in any of the documentation. I've confirmed I can't seem to make a new URI by hand that includes a "?" but all my Miva Generated URIs based on the URI Templates include the "?" just fine (but don't work). Wouldn't many miva websites that at one time used long URLs have question marks in the URL? Is it really not possible for those stores to set up 301 redirects from their Long URLs using URI Management?

    There's some discussion of putting those 301 redirects in the .htaccess file by hand but is that recommended? Even our smallish store has 400+ Long URL URIs.

    Also, somewhat related, can anyone confirm that you cannot include your store's "home" directory in the URI template? In other words, if your merchant.mvc file is inside /store/, you cannot successfully set your URI Product template to something like /store/product-name.html or even /store/p/product-name.html. Miva Support theorized this is true but I haven't seen that in documentation anywhere either.
    How can we handle urls that include ? and & using URI? The URI will not accept: /Merchant2/merchant.mvc?Screen=SFNT&Store_Code=WL I've tried: %3F

    #2
    URI management doesn't support query strings (Anything after the ?) in the URLs. You should not been able to even auto-generate URIs with the ? in them, if you were that may be a bug.

    Normally in this case we would recommend 301 redirects via the .htaccess file. If your new links contained the product code this would be possible with a few global rewrites. However in your case you're going from a Miva long link with query string parameters to a slugified product name URI. There is no way to globally map these using a few wildcard redirects in the .htaccess file.

    You have two options in this case:

    1. Add individual redirects in the .htaccess file for your product, categories and pages. There are limitations to how big this file can get so I would not recommend adding more than 500 total. Typically you can use use google analytics to find your top 500 URLs to redirect. You can then submit a google sitemap with your new URLs and google will eventually update the rest.

    2. The second option which we've done for a few clients is to have Miva do the redirects of you via template code. It looks something like this:

    Code:
    <mvt:assign name="l.uri:store_id" value="g.Store:id" />
    <mvt:assign name="l.uri:screen" value="''" />
    <mvt:assign name="l.uri:page_id" value="0" />
    <mvt:assign name="l.uri:cat_id" value="0" />
    <mvt:assign name="l.uri:product_id" value="l.settings:product:id" />
    
    <mvt:comment>Load canonical URI for this product</mvt:comment>
    <mvt:do file="g.Module_Feature_URI_DB" name="l.has_uri" value="URI_Load_Item_Canonical( l.uri, l.settings:product:uri )" />
    
    <mvt:if expr="l.has_uri">
        <mvt:assign name="l.settings:product:uri:redirect_to" value="l.settings:product:uri:uri" />
    
        <mvt:if expr="'/mm5/merchant.mvc' CIN s.request_uri EQ 1">
            <!-- REDIRECT! -->
            <mvt:assign name="l.header" value="miva_output_header( 'Status', '301 Moved Permanently' )" />
            <mvt:assign name="l.header" value="miva_output_header( 'Location', l.settings:product:uri:redirect_to  )" />
        </mvt:if>
    </mvt:if>

    This code would need to be modified slightly for categories or pages. It essentially looks for "/mm5/merchant.mvc" in the URI (i.e. long Miva link) and will then load the canonical URI for the product and do a 301 redirect to the canonical URI.


    You can make the URIs whatever you want. If you wan to include /store/ in the new URIs you'll just need to modify the master URI template to include /store/ then regenerate all your URIs




    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      Brennan,

      Thanks for your response- it's incredibly helpful. First, the URI Management appeared to allow me to generate URIs which included query strings. I can send more info if helpful in tracking that down. I'm on a fully updated 9.6 store.

      As far as going forward, yeah, I was hoping to keep the product code out of the url. I think the 301 redirect for the top few hundred URLs will work fine for me now that I know that's the expectation for stores migrating from Long URLs. Thanks for the guidance.

      For the last point, my contact within Miva Support is experiencing the same thing I am - if we set our URI templates to include the /store/ directory (in my case) or even in a subdirectory of it, we get 404 messages. Once we get the URIs out of that /store/ folder, we're good.

      Comment


        #4
        If "/store/" is your "/mm5" folder then you may run into issues since URI management ignores that folder. This is because you don't want URI management taking over a request for /store/merchant.mvc or /store/json.mvc

        You would need to modify the default .htaccess rules that miva creates for URI management to be able to use the store directory. Or change the directory back to mm5 then use /store in the URIs.

        Send me the ticket you have with support via email an I can log into your store and take a look to see what is the best path in your case.
        Brennan Heyde
        VP Product
        Miva, Inc.
        [email protected]
        https://www.miva.com

        Comment

        Working...
        X