Post by tkhki » Sat Dec 03, 2016 5:24 pm

Is it possible? My webhost don´t have addon domain possibility in cpanel. I can make subdomains but I can´t point them to same directory where my opencart is installed. I have asked my webhost help and one helper said that I could do it by .htaccess file and other said that it isn´t possible without vps package. I have tried couple htaccess guides, but didn´t work. My coding knowledge is not very good though.

So is it possible to somehow get multi-store to work or do I need to change webhost provider? I am using Opencart 2.3.0.2. Thank you for you help!

Newbie

Posts

Joined
Mon Nov 21, 2016 3:19 am


Post by artcore » Sat Dec 03, 2016 6:19 pm

I've been playing with a concept which you can read about here: http://ilithemes.com/docs/multistore-se ... subdomain/
It's a quick write-up on how to set up multi-stores without addon domain and DNS entries.
I haven't fully tested it and don't garantee any success but it's worth a shot for your case...

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by thekrotek » Sat Dec 03, 2016 6:28 pm

If you simply want to redirect visitors from subdomain to main domain, try this rule in .htaccess file:

Code: Select all

RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain.mysite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.subdomain.mysite\.com$
RewriteRule ^/?$ "http\:\/\/mysite\.com\/" [R=301,L]

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by tkhki » Sat Dec 03, 2016 9:15 pm

artcore wrote:I've been playing with a concept which you can read about here: http://ilithemes.com/docs/multistore-se ... subdomain/
It's a quick write-up on how to set up multi-stores without addon domain and DNS entries.
I haven't fully tested it and don't garantee any success but it's worth a shot for your case...
Thx, but it gave me only result to page.

require_once('../config.php'); require_once('../index.php');

Did I do something wrong?

Newbie

Posts

Joined
Mon Nov 21, 2016 3:19 am


Post by tkhki » Sat Dec 03, 2016 9:19 pm

thekrotek wrote:If you simply want to redirect visitors from subdomain to main domain, try this rule in .htaccess file:

Code: Select all

RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain.mysite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.subdomain.mysite\.com$
RewriteRule ^/?$ "http\:\/\/mysite\.com\/" [R=301,L]
Thx, this was not what I wanted. I need own store for subdomain, controlled in maindomain´s admin. Problem is that I can´t point subdomain to same folder than main domain in my cpanel.

Newbie

Posts

Joined
Mon Nov 21, 2016 3:19 am


Post by artcore » Sat Dec 03, 2016 10:04 pm

tkhki wrote: Thx, but it gave me only result to page.

require_once('../config.php'); require_once('../index.php');

Did I do something wrong?
Mmm yes it should read

Code: Select all

<?php
require_once('../config.php'); require_once('../index.php'); 
The <?php part fell off. Thx I'll fix it in the doc

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by danbrun » Tue Dec 06, 2016 3:00 am

artcore wrote:
tkhki wrote: Thx, but it gave me only result to page.

require_once('../config.php'); require_once('../index.php');

Did I do something wrong?
Mmm yes it should read

Code: Select all

<?php
require_once('../config.php'); require_once('../index.php'); 
The <?php part fell off. Thx I'll fix it in the doc
Hi I have the same problem and tested the solution you have suggested artcore. I followed the steps from the link and it seems like a second store is created successfully but the formating isn't there at all. I suppose the links to the stylesheets, images and javascripts doesn't really work? I'm also running OpenCart 2.3.0.2 and catalog/controller/common/header.php is a bit different now so I tried a few things but nothing really happened? Maybe you could have a look on code and suggest where I should put " $server = HTTPS_SERVER; "

Code: Select all

<?php
class ControllerCommonHeader extends Controller {
	public function index() {
		// Analytics
		$this->load->model('extension/extension');

		$data['analytics'] = array();

		$analytics = $this->model_extension_extension->getExtensions('analytics');

		foreach ($analytics as $analytic) {
			if ($this->config->get($analytic['code'] . '_status')) {
				$data['analytics'][] = $this->load->controller('extension/analytics/' . $analytic['code'], $this->config->get($analytic['code'] . '_status'));
			}
		}

		if ($this->request->server['HTTPS']) {
			$server = $this->config->get('config_ssl');
		} else {
			$server = $this->config->get('config_url');
		}

		if (is_file(DIR_IMAGE . $this->config->get('config_icon'))) {
			$this->document->addLink($server . 'image/' . $this->config->get('config_icon'), 'icon');
		}

		$data['title'] = $this->document->getTitle();

		$data['base'] = $server;
		$data['description'] = $this->document->getDescription();
		$data['keywords'] = $this->document->getKeywords();
		$data['links'] = $this->document->getLinks();
		$data['styles'] = $this->document->getStyles();
		$data['scripts'] = $this->document->getScripts();
		$data['lang'] = $this->language->get('code');
		$data['direction'] = $this->language->get('direction');

		$data['name'] = $this->config->get('config_name');

		if (is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
			$data['logo'] = $server . 'image/' . $this->config->get('config_logo');
		} else {
			$data['logo'] = '';
		}

		$this->load->language('common/header');

		$data['text_home'] = $this->language->get('text_home');

		// Wishlist
		if ($this->customer->isLogged()) {
			$this->load->model('account/wishlist');

			$data['text_wishlist'] = sprintf($this->language->get('text_wishlist'), $this->model_account_wishlist->getTotalWishlist());
		} else {
			$data['text_wishlist'] = sprintf($this->language->get('text_wishlist'), (isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0));
		}

		$data['text_shopping_cart'] = $this->language->get('text_shopping_cart');
		$data['text_logged'] = sprintf($this->language->get('text_logged'), $this->url->link('account/account', '', true), $this->customer->getFirstName(), $this->url->link('account/logout', '', true));

		$data['text_account'] = $this->language->get('text_account');
		$data['text_register'] = $this->language->get('text_register');
		$data['text_login'] = $this->language->get('text_login');
		$data['text_order'] = $this->language->get('text_order');
		$data['text_transaction'] = $this->language->get('text_transaction');
		$data['text_download'] = $this->language->get('text_download');
		$data['text_logout'] = $this->language->get('text_logout');
		$data['text_checkout'] = $this->language->get('text_checkout');
		$data['text_category'] = $this->language->get('text_category');
		$data['text_all'] = $this->language->get('text_all');

		$data['home'] = $this->url->link('common/home');
		$data['wishlist'] = $this->url->link('account/wishlist', '', true);
		$data['logged'] = $this->customer->isLogged();
		$data['account'] = $this->url->link('account/account', '', true);
		$data['register'] = $this->url->link('account/register', '', true);
		$data['login'] = $this->url->link('account/login', '', true);
		$data['order'] = $this->url->link('account/order', '', true);
		$data['transaction'] = $this->url->link('account/transaction', '', true);
		$data['download'] = $this->url->link('account/download', '', true);
		$data['logout'] = $this->url->link('account/logout', '', true);
		$data['shopping_cart'] = $this->url->link('checkout/cart');
		$data['checkout'] = $this->url->link('checkout/checkout', '', true);
		$data['contact'] = $this->url->link('information/contact');
		$data['telephone'] = $this->config->get('config_telephone');

		// Menu
		$this->load->model('catalog/category');

		$this->load->model('catalog/product');

		$data['categories'] = array();

		$categories = $this->model_catalog_category->getCategories(0);

		foreach ($categories as $category) {
			if ($category['top']) {
				// Level 2
				$children_data = array();

				$children = $this->model_catalog_category->getCategories($category['category_id']);

				foreach ($children as $child) {
					$filter_data = array(
						'filter_category_id'  => $child['category_id'],
						'filter_sub_category' => true
					);

					$children_data[] = array(
						'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
						'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
					);
				}

				// Level 1
				$data['categories'][] = array(
					'name'     => $category['name'],
					'children' => $children_data,
					'column'   => $category['column'] ? $category['column'] : 1,
					'href'     => $this->url->link('product/category', 'path=' . $category['category_id'])
				);
			}
		}

		$data['language'] = $this->load->controller('common/language');
		$data['currency'] = $this->load->controller('common/currency');
		$data['search'] = $this->load->controller('common/search');
		$data['cart'] = $this->load->controller('common/cart');

		// For page specific css
		if (isset($this->request->get['route'])) {
			if (isset($this->request->get['product_id'])) {
				$class = '-' . $this->request->get['product_id'];
			} elseif (isset($this->request->get['path'])) {
				$class = '-' . $this->request->get['path'];
			} elseif (isset($this->request->get['manufacturer_id'])) {
				$class = '-' . $this->request->get['manufacturer_id'];
			} elseif (isset($this->request->get['information_id'])) {
				$class = '-' . $this->request->get['information_id'];
			} else {
				$class = '';
			}

			$data['class'] = str_replace('/', '-', $this->request->get['route']) . $class;
		} else {
			$data['class'] = 'common-home';
		}

		return $this->load->view('common/header', $data);
	}
}

UPDATE:
When I analyzed the html code (by right clicking on the web page and choose "View page source") I could see that the css, javascript and the images were referring to wrong paths. Since I've created a new subfolder the base href in the html header will be http://domain.com/subfolder/ and paths are relative this one. Since there are no folders at all in the subdomain folder, no scrips will be found because they are located one level up, see code:

Code: Select all

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Release</title>
<base href="http://domain.com/subfolder/" />
<script src="catalog/view/javascript/jquery/jquery-2.1.1.min.js" type="text/javascript"></script>
<link href="catalog/view/javascript/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen" />
<script src="catalog/view/javascript/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<link href="catalog/view/javascript/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,400i,300,700" rel="stylesheet" type="text/css" />
<link href="catalog/view/theme/default/stylesheet/stylesheet.css" rel="stylesheet">
<link href="catalog/view/javascript/jquery/owl-carousel/owl.carousel.css" type="text/css" rel="stylesheet" media="screen" />
<script src="catalog/view/javascript/common.js" type="text/javascript"></script>
<script src="catalog/view/javascript/jquery/owl-carousel/owl.carousel.min.js" type="text/javascript"></script>
</head>


If I add "../" to all paths the css and javascrips will start to work again:

Code: Select all

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Release</title>
<base href="http://domain.com/subfolder/" />
<script src="../catalog/view/javascript/jquery/jquery-2.1.1.min.js" type="text/javascript"></script>
<link href="../catalog/view/javascript/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen" />
<script src="../catalog/view/javascript/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<link href="../catalog/view/javascript/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,400i,300,700" rel="stylesheet" type="text/css" />
<link href="../catalog/view/theme/default/stylesheet/stylesheet.css" rel="stylesheet">
<link href="../catalog/view/javascript/jquery/owl-carousel/owl.carousel.css" type="text/css" rel="stylesheet" media="screen" />
<script src="../catalog/view/javascript/common.js" type="text/javascript"></script>
<script src="../catalog/view/javascript/jquery/owl-carousel/owl.carousel.min.js" type="text/javascript"></script>
</head>
How can I solve this problem for the new store created in the subfolder?

Newbie

Posts

Joined
Sun Dec 04, 2016 11:14 pm

Post by artcore » Sat Dec 10, 2016 3:00 am

Sorry I didn't see your reply as I don't get notifications from forum posts anymore.

Change
$data['base'] = $server;
to
$data['base'] = HTTPS_SERVER;

and revert the changes you made in the header.tpl (../ and restore the $base variable too)

Please note I only tested it on 1.5X and not fully. It's a concept we're playing with here ;)

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands
Who is online

Users browsing this forum: No registered users and 20 guests