skip to Main Content

I am trying that when someone opens this link: [url]www.example.com/invite/1234randomhashtag[/url]

Will be redirected to:

www.example.cloud/index.php?cl=register_new_user&fnc=register&hash=1234randomhashtag

Now this can easily be done with the PHP header.

However I have also found the oxutilsurl class. Is it even possible to do this with this class? Does it help?

2

Answers


  1. OXID has no dynamic routing based on url parts.
    There is a SEO URL entry in the database for every valid SEO Url.

    You could generate a SEO Url when someone uses your invitation function and remove the url after couple of months.
    Or you need to change your generated urls a bit and make it look like this:
    http://www.example.com/invite#1234randomhashtag with # instead of /
    and then parse your hash from $_SERVER["REQUEST_URI"] and set your variables or redirect to the final URL

    But you still could solve this outside of OXID with .htacess rewrite rules (i guess) or another php micro framework like “Slim” or “Lumen” running in /invite/ directory and redirecting your visitor back to the shop

    Login or Signup to reply.
  2. Oxid does not support you by changing the original oxid routing mechanics in a way that they would work for you. There is a way to set up static redirects within the general settings inside the oxid admin backend (see SEO tab). But those do not support wildcards (/invite/*) like you would need them.

    Theoretically speaking, if you really wanted to have a solution for this one inside an oxid module (to avoid hacking the core, and having it bundled within a module) you could extend one of several oxid functions that are being called before oxids very own mvc based routing logic is reached and manually redirect at that point. Basically this could be done in every core function that is being called before you get routed to the 404 page (oxseodecoder::processSeoCall)

    Considering the official info from oxid, that lists the non overloadable classes, you should be able to extend oxshopcontrol::start (or even oxseodecoder::processSeoCall) and add something like the following:

    if(preg_match("//invite/.*/", $_SERVER['REQUEST_URI'])){
    
        $randomHash =  basename($_SERVER['REQUEST_URI']);
        oxRegistry::getUtils()->redirect($this->getConfig()->getShopURL().'index.php?cl=register_new_user&fnc=register&hash='.$randomHash , false, 301);
    
    }
    

    Anyway, I think the simplest, fastest and most performant approach on this one would be setting up url redirects within the .htaccess file inside your shops root directory.

    The following should work:

    RewriteRule    ^invite/([A-Za-z0-9-]+)/?$    index.php?cl=register_new_user&fnc=$1    [NC,L] 
    

    You could put that code immediately under RewriteBase / inside the .htaccess file within your shops root directory.

    I put that rewrite rule together with information from this article.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search