Auckland Magento User Group Message Board › Multiple Store / Multi Domain / One Magento

Multiple Store / Multi Domain / One Magento

Rian H.
user 13010893
Sydney, AU
Post #: 1
Anyone else set this up ????

I want to run two store views with different domains with one backend.

Has anyone else set this up ?

I keep getting a stupid error ???
Robert
user 4396114
Auckland, NZ
Post #: 4
Anyone else set this up ????

I want to run two store views with different domains with one backend.

Has anyone else set this up ?

I keep getting a stupid error ???

Yep, this is pretty straight-forward. There are a few tutorials online if you search on google and there are different ways to set up the domains depending on how you want to handle it.

Best way is via the apache vhosts entries, but you can use .htaccess as well.

You need to provide more info on how you set it up and what that stupid error is if you're still stuck.

Cheers, Robert
Rian H.
user 13010893
Sydney, AU
Post #: 2
Thanks for the reply Robert.

Yip i've tried about 5 of the tutorials now but I still get an error.

I'm using the htaccess method since im running on shared hosting.

Here is my htaccess file and index.php


##Store code:hid

RewriteCond %{HTTP_HOST} ^(.*)hidreplacements.co.nz
RewriteRule ^ - [E=MAGE_RUN_CODE:hid]


######################################­######
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
## it might be /cgi-bin/php-cgi

# Action php5-cgi /cgi-bin/php5-cgi
# AddHandler php5-cgi .php

######################################­######
## GoDaddy specific options

# Options -MultiViews

## you might also need to add this line to php.ini
## cgi.fix_pathinfo = 1
## if it still doesn't work, rename php.ini to php5.ini

######################################­######
## this line is specific for 1and1 hosting

#AddType x-mapp-php5 .php
#AddHandler x-mapp-php5 .php

######################################­######
## default index file

DirectoryIndex index.php

<IfModule mod_php5.c>

######################################­######
## adjust memory limit

# php_value memory_limit 64M
php_value memory_limit 128M
php_value max_execution_time 18000

######################################­######
## disable magic quotes for php request vars

php_flag magic_quotes_gpc off

######################################­######
## disable automatic session start
## before autoload was initialized

php_flag session.auto_start off

######################################­######
## enable resulting html compression

#php_flag zlib.output_compression on

######################################­#####
# disable user agent verification to not break multiple image upload

php_flag suhosin.session.cryptua off

######################################­#####
# turn off compatibility with PHP4 when dealing with objects

php_flag zend.ze1_compatibility_mode Off

</IfModule>

<IfModule mod_security.c>
######################################­#####
# disable POST processing to not break multiple image upload

SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

<IfModule mod_deflate.c>

######################################­######
## enable apache served files compression
## http://developer.yaho...­

# Insert filter on all content
###SetOutputFilter DEFLATE
# Insert filter on selected content types only
#AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

# Netscape 4.x has some problems...
#BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
#BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
#BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Don't compress images
#SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
#Header append Vary User-Agent env=!dont-vary

</IfModule>

<IfModule mod_ssl.c>

######################################­######
## make HTTPS env vars available for CGI mode

SSLOptions StdEnvVars

</IfModule>

<IfModule mod_rewrite.c>

######################################­######
## enable rewrites

Options +FollowSymLinks
RewriteEngine on

######################################­######
## you can put here your magento root folder
## path relative to web root

#RewriteBase /magento/

######################################­######
## workaround for HTTP authorization
## in CGI environment

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorizati­on}]

######################################­######
## always send 404 on missing files in these folders

RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

######################################­######
## never rewrite for existing files, directories and links

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

######################################­######
## rewrite everything else to index.php

RewriteRule .* index.php [L]

</IfModule>


######################################­######
## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead

AddDefaultCharset Off
#AddDefaultCharset UTF-8

<IfModule mod_expires.c>

######################################­######
## Add default Expires header
## http://developer.yaho...­

ExpiresDefault "access plus 1 year"

</IfModule>

######################################­######
## By default allow all access

Order allow,deny
Allow from all

######################################­######
## If running in cluster environment, uncomment this
## http://developer.yaho...­

#FileETag none

and the index.php


$compilerConfig = 'includes/config.php';
if (file_exists($compilerConfig)) {
include $compilerConfig;
}

$mageFilename = ‘../public_html/app/Mage.php’;
$maintenanceFile = 'maintenance.flag';

if (!file_exists($mageFilename)) {
if (is_dir('downloader')) {
header("Location: downloader");
} else {
echo $mageFilename." was not found";
}
exit;
}

if (file_exists($maintenanceFile)) {
$basePath = dirname($_SERVER['PHP_SELF']);
include_once dirname(__FILE__) . '/errors/503.php';
exit;
}

require_once $mageFilename;

#Varien_Profiler::enable();

if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'­])) {
Mage::setIsDeveloperMode(true);
}

#ini_set('display_errors', 1);

umask(0);

$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

Mage::run(hid, 'www.hidreplacements.co.nz');

My current error is as below

www.hidreplacements.co.nz

Any help is very appreciated !


Robert
user 4396114
Auckland, NZ
Post #: 5
Well, the error is pretty clear. You got a '.' (period) on line 45 in oindex.php which shouldn't be there. I suppose it comes from the line:

Mage::run(hid, 'www.hidreplacements.co.nz');

hid isn't in quotes as it would be a string parameter passed to the run method.

Besides, it's actually not correct to put your domain in the second parameter. You don't need to change the index.php at all. You should change that line back to:

Mage::run($mageRunCode, $mageRunType);

Those codes will be set up in your .htaccess

Your Rewrite rules should be added after the 'RewriteEngine On' directive.

Try that and report back.
Rian H.
user 13010893
Sydney, AU
Post #: 3
Hi Robert,

Ive converted it back to the orginal index.php

my error is now

app/Mage.php was not found

Error log states:

[12-Sep-2011 13:54:00] PHP Warning: Module 'PDO' already loaded in Unknown on line 0
[12-Sep-2011 13:54:00] PHP Warning: Module 'pdo_sqlite' already loaded in Unknown on line 0
[12-Sep-2011 13:54:00] PHP Warning: Module 'SQLite' already loaded in Unknown on line 0
[12-Sep-2011 13:54:00] PHP Warning: Module 'pdo_mysql' already loaded in Unknown on line 0

Any ideas ??
Rian H.
user 13010893
Sydney, AU
Post #: 4
Hey AMUG,

I've still got issue and i'm spending more time trying to sort my infrastructure to run my own webserver so I can have full control over my webserver and fix this rather than trying to work around the issue.

A steep learning curve as my linux skilsl are pretty limited.

Do I need SSH to get his to work ? or does someone know of a way to get this to work with out SSH ??

I have everything setup in Magento it just wont point from my domain back to magento.

Anyone have experience running multiple domains from one admin backend with magento ??

Rian H.
user 13010893
Sydney, AU
Post #: 5
I sort of got this to work so I thought I would post up my results.

First off If u have 2 x domains

Vup.co.nz and Vupother.co.nz

Vup.co.nz is my install of Magento.
Vupother.co.nz is just a new domain

First thing you need to do is copy these files over from the working magento root directory

Index.php
and httacess

Open Index.php and find mage/app change it to you working directory so its now prob ../mage/app

or if you run your magento under a subdomain ../(subdomain)/mage/app

close and save

open httacess

add this code

SetEnvIf Host .*base.* MAGE_RUN_CODE=base
SetEnvIf Host .*base.* MAGE_RUN_TYPE=website
SetEnvIf Host .*(other store code).* MAGE_RUN_CODE=(other store code)
SetEnvIf Host .*(other store code).* MAGE_RUN_TYPE=website

Now this is the downside of this method. you now need to copy the image and working files over to the other domain.

This didnt seem so bad until i tried to add a image to VupOther. then realised I had to manually copy the image over to the other domain for it to work.

That seem very backwards to me and sort of totally goes againist why you would run magento in the first place.

So now im trying to figure out how to run it all from the single root directory.

Any suggestions greatly appriciated
Robert
user 4396114
Auckland, NZ
Post #: 6
You don't need to copy anything.

Why don't you use the procedures outlined either here: http://www.magentocom...­

or here: http://www.magentocom...­

You should be able to do it all via the apache VHOSTS, or .htaccess. No need to edit any index.php files or make subdirectories and copy files.

I suggest you undo any custom edits to your Magento index.php
Rian H.
user 13010893
Sydney, AU
Post #: 6
There seems to be alot of bogus (or older version ) information circulating on the net.

However to do this was actually really simple using the add domain method.

once you find out what works and what doesn't..... that is ?

All I needed was some code in my .htaccess in website2.com to control what traffic goes where.

and the some code in my website1.com index.php to control the store switching between website1.com and website2.com

Then jump into magento admin and reroute the media and skin directories back to website1.com

And booooommm!!!!!

www.store.visionup.co.nz
www.hidreplacements.co.nz (Work in progress!)
Pratik
user 41388872
Auckland, NZ
Post #: 3
ok ck it
htaccess
-------------

######################################­######
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
## it might be /cgi-bin/php-cgi

# Action php5-cgi /cgi-bin/php5-cgi
# AddHandler php5-cgi .php

######################################­######
## GoDaddy specific options

# Options -MultiViews

## you might also need to add this line to php.ini
## cgi.fix_pathinfo = 1
## if it still doesn't work, rename php.ini to php5.ini

######################################­######
## this line is specific for 1and1 hosting

#AddType x-mapp-php5 .php
#AddHandler x-mapp-php5 .php

######################################­######
## default index file

DirectoryIndex index.php

<IfModule mod_php5.c>

######################################­######
## adjust memory limit

# php_value memory_limit 64M
php_value memory_limit 256M
php_value max_execution_time 18000

######################################­######
## disable magic quotes for php request vars

php_flag magic_quotes_gpc off

######################################­######
## disable automatic session start
## before autoload was initialized

php_flag session.auto_start off

######################################­######
## enable resulting html compression

#php_flag zlib.output_compression on

######################################­#####
# disable user agent verification to not break multiple image upload

php_flag suhosin.session.cryptua off

######################################­#####
# turn off compatibility with PHP4 when dealing with objects

php_flag zend.ze1_compatibility_mode Off

</IfModule>

<IfModule mod_security.c>
######################################­#####
# disable POST processing to not break multiple image upload

SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

<IfModule mod_deflate.c>

######################################­######
## enable apache served files compression
## http://developer.yaho...­

# Insert filter on all content
###SetOutputFilter DEFLATE
# Insert filter on selected content types only
#AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

# Netscape 4.x has some problems...
#BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
#BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
#BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Don't compress images
#SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
#Header append Vary User-Agent env=!dont-vary

</IfModule>

<IfModule mod_ssl.c>

######################################­######
## make HTTPS env vars available for CGI mode

SSLOptions StdEnvVars

</IfModule>

<IfModule mod_rewrite.c>

######################################­######
## enable rewrites

Options +FollowSymLinks
RewriteEngine on

######################################­######
## you can put here your magento root folder
## path relative to web root

#RewriteBase /magento/

######################################­######
## workaround for HTTP authorization
## in CGI environment

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorizati­on}]

######################################­######
## always send 404 on missing files in these folders

RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

######################################­######
## never rewrite for existing files, directories and links

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

######################################­######
## rewrite everything else to index.php

RewriteRule .* index.php [L]

</IfModule>


######################################­######
## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead

AddDefaultCharset Off
#AddDefaultCharset UTF-8

<IfModule mod_expires.c>

######################################­######
## Add default Expires header
## http://developer.yaho...­

ExpiresDefault "access plus 1 year"

</IfModule>

######################################­######
## By default allow all access

Order allow,deny
Allow from all

######################################­#####
## Deny access to release notes to prevent disclosure of the installed Magento version

<Files RELEASE_NOTES.txt>
order allow,deny
deny from all
</Files>

######################################­######
## If running in cluster environment, uncomment this
## http://developer.yaho...­

#FileETag none


index.php
-------------

<?php

if (version_compare(phpversion(), '5.2.0', '<')===true) {
echo '<div style="font:12px/1.35em arial, helvetica, sans-serif;"><div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;"><h3 style="margin:0; font-size:1.7em; font-weight:normal; text-transform:none; text-align:left; color:#2f2f2f;">Whoops, it looks like you have an invalid PHP version.</h3></div><p>­Magento supports PHP 5.2.0 or newer. <a href="http://www.magentocom...­ target="">Find out</a> how to install</a> Magento using PHP-CGI as a work-around.</p></div>';
exit;
}

error_reporting(E_ALL | E_STRICT);
$compilerConfig = '../includes/config.php';
if (file_exists($compilerConfig)) {
include $compilerConfig;
}
$mageFilename = '../app/Mage.php';
$maintenanceFile = 'maintenance.flag';
if (!file_exists($mageFilename)) {
if (is_dir('downloader')) {
header("Location: downloader");
} else {
echo $mageFilename." was not found";
}
exit;
}
if (file_exists($maintenanceFile)) {
include_once dirname(__FILE__) . '/errors/503.php';
exit;
}
require_once $mageFilename;
#Varien_Profiler::enable();
if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'­])) {
Mage::setIsDeveloperMode(true);
}
#ini_set('display_errors', 1);
umask(0);
//$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
//$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
//Mage::run($mageRunCode, $mageRunType);
Mage::run('newweb', 'website');

Here My New Website Name is newweb and application name is magentopratik its work..
check out this link

http://www.magentocom...­
Powered by mvnForum

Our Sponsors

  • Lero9

    LERO9 provide the space for the Magento Meetups.

  • Fooman

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy