Set envif Host Magento Multiple Stores - magento

I am trying to get a magento installation to run multiple websites I have completed most of the steps including a parked domain. However I am unsure as to how to answer the statement below:
Easiest amongst these is .htaccess solution which requires you to define the following lines:
SetEnvIf Host .*myhost.* MAGE_RUN_CODE="base";
SetEnvIf Host .*myhost.* MAGE_RUN_TYPE="website";
Simply ensure that .myhost. is a regex expression matching the domain for which you want to set environmental variables for.
For example do my website is www.domain.com and also www.domain1.com, magento is installed on domain.com so for the host do I put .domain.com. and leave the run code and type and base and website

What you are supposed to change is the MAGE_RUN_CODE to match the code of the site that is managed in the Magento backend. You also need to change the myhost bit match the domain name of your site.
So for example, if your site is hosted on somewebsite.com and you have two "stores" (Store View A and Store View B, Where "ViewA" is Store View A and "ViewB" is Store View B.)
You would write the following:
SetEnvIf Host .*somewebsite.* MAGE_RUN_CODE=ViewA
SetEnvIf Host .*somewebsite.* MAGE_RUN_TYPE=website
SetEnvIf Host .*somewebsite.* MAGE_RUN_CODE=ViewB
SetEnvIf Host .*somewebsite.* MAGE_RUN_TYPE=website
This assuming you made two different "Sites" in the Magento Backend. If you made a different store, you'd replace "website" with store.
More reading on the Magento renaming can be found here:
http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/navigation/multiple-website-setup

Related

Laravel Ngrok and absolute URLs

I used this command to startup ngrok for a laravel site, namely testsite.local:
ngrok http -host-header=rewrite testsite.local:80
I have testsite.local defined in /etc/hosts to map to 127.0.0.1
This works, Ngrok starts up just fine and now serves the local site on some random *.ngrok.io address, which I can access. But all URLs within the laravel application (e.g. internal links, or urls for loading a css or js file) are absolute urls to my locally defined domain, like http://testsite.local/news, or http://testsite.local/css/styles.css. In other words, I can load the site fine, but anyone else just sees a bunch of unstyled html and gets a non functional site.
This has to be a general issue for anyone who uses ngrok and has absolute URLs within their project, but google didn't yield anything useful.
Two possible approaches come to my mind:
rewrite all links in the application to be relative instead of
absolute (oh god please no)
any client that wants to access my site via the *.ngrok.io url has to map the 'testsite.local' domain within their very own /etc/hosts file to the ngrok.io url.
The approaches may work, but this seems so far stretched... isn't there anything else one can do?
SOLUTION
https://stackoverflow.com/a/54488972/718980
You need to use Apache Module mod_substitute.
First, enable module:
a2enmod substitute
service apache2 restart
Then, add the following to the .htaccess file:
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|<your-local-link>|<your-ngrok-link>|in"
More information: https://httpd.apache.org/docs/2.4/mod/mod_substitute.html
In xammp/apache/conf/httd.conf
DocumentRoot "C:/xampp/htdocs/{your-project-path}"
Directory "C:/xampp/htdocs/{your-project-path}"
In the httpd.conf set your DocumentRoot and Directory to the path of your project.
DocumentRoot "C:/xampp/htdocs/projectName"
<Directory "C:/xampp/htdocs/projectName">

Should Magento base url include www?

In the Magento installation wizard, should the base url include www or not?
Ex: www.site.com or site.com
If you plan on using a cdn to distribute your images, etc. yes, it would be a really, really good idea to have your web server use a www. host name instead of using only the bare domain name.
It's not cool when your customers start having blecherous cookie problems due to not using proper host names to sort out the different cname entries in your DNS.
Changing after the fact results in humorous non-SEO friendly reindexing by Google, Bing, et. al.

magento base url for root category

I have several windows in one shop. How can I make Magento use Base URL of Magento settings? Now it duplicates the same item for all windows even if the shop is attached to the catalogue’s root directory.
It means that one item exists on different domains but it placed in the same category of the catalogue
subdomain1/nokia1280
...
subdomain3/nokia1280
URL Rewrite Management does not help
I am not sure what the question is but if you want to use multible domains with products you should do the following:
Foreach subdomain
Redirect the subdomain to the magento shop ( vhost alias for example )
Change the .htaccess to set the environment based on Referer
Add a new Root category for this domain
Create a new Store with Storeview
Go to Sysem => Configuration => Web and select the storeview top left
Change the base URLS to the subdomain for this store.
Go to System => Configuration => Design and change the template / skin / layout for this store
Now will your subdomain be loaded within his own environment, with his own template and skin.
More information
Use websites
Notice that users will be shared along the different domains. If you
don`t want this you should go a level further and make more websites.
.htaccess set environment
SetEnvIf Host sub1.website.dev MAGE_RUN_CODE=subdomain1
SetEnvIf Host sub1.website.dev MAGE_RUN_TYPE=store
SetEnvIf Host sub2.website.dev MAGE_RUN_CODE=subdomain2
SetEnvIf Host sub2.website.dev MAGE_RUN_TYPE=store
Hope this will help !
Good luck.

How to migrate a Magento Installation to localhost

I've been following several guides over the internet, but I still can't access my Magento (1.6) website from localhost ..
I dumped the DB and imported it to phpMyAdmin, copied the files from the server to my localhost (WAMP), updated local.xml and have been to the core_config_data table and changed web/unsecure/base_url to new URL & web/secure/base_url to new URL.
Is there anything else to do ?
I've seen that sometimes, in some guides, they're asking to go to C:\windows\system32\drivers\etc\hosts and insert the following lines: 127.0.0.1 www.mydomain.com mydomain.com
But I already did this to www.localhost.com since I already have several websites I need to run from localhost, I don't want to change that ..
So when I launch the website from www.localhost.com/mywebsite I'm redirected to the old address and my browser says "Oops! Google Chrome could not find 'the old address' "
Any suggestion would be welcome :)
As long as core_config_data.path values are updated correctly (double-check), the only other thing (besides Magento's PHP code) that could do a redirect is an .htaccess file with a RewriteCond and RewriteRule directive. This also could be present in the VirtualHost.
As another option, you could edit the Windows Hosts file, and resolve your old domain name to 127.0.0.1 and update your VirtualHost's ServerAlias line to include that domain name.
Maybe check that web/cookie/cookie_path and web/cookie/cookie_domain are correctly set into the core_config_data table. I usually delete values of these 2 fields when switching from a server to another.
Also always think of disabling cache before dumping your DB as this can avoid some struggling too.

Magento 1.6.2 Multiple Stores

I am trying to integrate multiple magento sites within the one installation. From what I have found i need to use a parked domain method however I have tried various methods to get it all working however I keep getting the 2nd store redirecting to the main store so I am looking for the best method to allow me to run multiple websites.
Any help is greatly appreciated
We currently have 4 stores all sharing one Magento installation & set of products. Each has it's own unique URL.
Create your Stores
Go to System -> Manage Stores
Click on Create Website. In the Name field, enter your store name. In the Code field, enter a unique code [lowercase & without spaces - we're going to give it a code of domain1 for our example] (to be used later) & Save.
Click on Create Store. In the Website field, select the website from step 2. In the Name field, enter a name. In the Root Category field, select the Root Category for your store & Save.
Click on Create Store View. Select the store you just created (from the dropdown menu) for Store. Type a name for your store in the Name field (Example from Magento is English Store). In the Code field, enter a unique string to identify the store view (just like for your store). Change the Status to Enabled & Save.
Repeat for all your stores
Configure your stores in the Magento Admin Configuration Section
Go to System -> Configuration
In the Store Scope (top-left dropdown), choose your first Store.
Choose Web from the Left-side menu
Open the Unsecure & Secure sections
Change the domains to what they would be (i.e. - http://www.domain1.com/) Don't forget the trailing slash at the end
Repeat for all stores
Server Config (for Magento versions 1.4.0.1 and greater)
Point your domain (e.g. - www.domain1.com) to your server where your single Magento instance is installed
Set up a Pointer/Parked domain on your server (see your Host's instructions or contact them)
In the .htaccess file on the root of your install, put in the following code for each of your stores
SetEnvIf Host .*domain1.com
MAGE_RUN_CODE=domain1 <- This was your important code from step 2 under Create your Stores SetEnvIf Host
.*domain1.com MAGE_RUN_TYPE=website
This set of 2 must be repeated for every domain you have.
For our particular stores/domains (might find useful)
Some servers, particularly those running Litespeed Web Server, the SetEnvIf directive does not get recognized in the .htaccess file. This was particularly true for us.
We had to do the following
Find RewriteBase / or RewriteBase /magento/ or etc
RewriteCond %{HTTP_HOST} .domain1.com [NC]
RewriteRule . - [E=MAGE_RUN_CODE:domain1]
RewriteCond %{HTTP_HOST} .domain1.com [NC]
RewriteRule . - [E=MAGE_RUN_TYPE:website]
We also have symlinks set up on our server (under each or our domains) to point to our main domain's folders (for the app, includes, js, lib, media, shell, skin, var)
Multi Store in Magento v1.6.2
in the VirtualHost configuration set the DocumentRoot to where you have your Magento installed (something like /var/www/magento), so it will be the same for every domain as we want only one Magento install for each domain
in Magento's admin, go to System -> Manage Stores and create your websites with their stores and store views (before that you'll have created one root category for each website). Reindex after everything is created
go to System -> Configuration and change the scope (the dropdown on the upper left) to one of the website. Go to the (General) Web -> Unsecure tab, uncheck the "Use Default" and indicate the domain in the Base URL field. Do the same for the secure
open the .htaccess at the root of your Magento install and at the end of it add the rules to determine which website to show according to the domain. For example, if you have set the codes website1 for domain1.com and website2 for domain2.com, put this:
SetEnvIf Host ^domain1.com$ MAGE_RUN_CODE=website1
SetEnvIf Host ^domain2.com$ MAGE_RUN_CODE=website2
SetEnv MAGE_RUN_TYPE website
and you're all set :)
HTH
Did you change your base urls for the second store configuration?
Navigate to:
System>Configuration>Web>Unsecure
System>Configuration>Web>Secure
Then change the Current Configuration Scope (top of left sidebar): your second store config
Deselect use default and enter your second store's path:
Base URL : http://yourdomain.com/
Secure Base URL: https://yourdomain.com/

Resources