Jump to content

Need to Use Wildcard Sub Domains for 1 Shop: How?


IeM

Recommended Posts

Hi,

I need my single shop store to be able to use wildcard subdomains and do not know how to achieve this or anyone who can.

 

WHY: My Affiliates all have affiliate codes such as 'john'. These codes are the subdomains eg. "john.shop.com"    It is a very neat way of tracking affiliates not having to add URL variables. This way also looks better and is better for a number of marketing reasons. It could be done with earlier Prestashop versions without mods.Our other system rely on this form of tracking. Also, if a customer bookmarks a page, it will not include the affiliates referrer code and that affiliate looses the customer which is not acceptable.

 

The sever is set up to use "*.shop.com" (wildcard) but off course if you go to "john.shop.com" what loads due to the way Prestashop 1.6 now works is "www.shop.com".

 

It gets worse: If you go to  "john.advantagelife.net/home/1-product.html"  what loads is "www.shop.com" so affiliates can not send customers directly to a product or any other page other than the home page.

 

As multi-stores is not going to be used, I do not care if that functionality is totally overridden.

 

While it would greatly be preferable to be dynamic and not do a database call for the sub-domain, I do keep a copy of the affiliate codes in the customer table. It would be better if the 1.6 functionality of rewriting the URL as "www....." was simply removed or overridden.

 

Does anyone have the knowledge on how to achieve this?

 

Thanks

 

 

Link to comment
Share on other sites

  • 3 weeks later...

here is 1.4 code for 'any domain', this code would need to be upgraded to work in a 1.5+ shop, in 1.4 we use a class override of Configuration, this code goes at the end.  (note this code has additional benefit of ignoring use or lack of use of www (so you don't lose cart items/login etc)

if (!str_replace('www.', null, Configuration::get('PS_SHOP_DOMAIN')) == (str_replace('www.', null, $host))) 
   Configuration::set('PS_SHOP_DOMAIN', isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']);		
Link to comment
Share on other sites

Hi El Patron,

Thank you for your assistance.

 

I'm finding it more complicated than the suggestion as I went into class shop, class shopurl. class link, and changed as much as I could to do with the domain name by overriding the DB calls etc.

 

I had 90% success but then there was cache issues even though I overrode some of that.

 

This is turning out to be very hard to override for some reason.

 

Unless someone has done it and has the override code they can share, I'm now going back to setting up a duplicate shop for each affiliate which involves over 41 tables. This has to be done automatically from another site (no webservice for this) so I am now seeing if I can do this via the Shop class.

 

Any suggestions are welcome and thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...