Monday, June 26, 2017

Google PageSpeed Insights suggests "Leverage browser caching"

Add following into .htaccess file
##### EXPIRE CACHING - LEVERAGE BROWSER CACHING #####
<IfModule mod_headers.c>
# WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=604800, public"
</FilesMatch>
</IfModule>
##### END EXPIRE CACHING #####

Saturday, June 24, 2017

Enhance your ad with extensions

Give customers more reason to click your ad by including extra information about your business -- by adding an ad extension. This course will show you how ad extensions make your ad more eye catching and encourage higher clickthrough rates. 

Sitelinks: Give customers quick access to multiple pages of your website.
Call extensions: Let people click a button to call you. 
Seller ratings: Showcase customers’ reviews and ratings of their experience with your business.
App extensions: Display a link below your ad text that sends people to the app store or starts downloading your app.
Location extensions: Share location details -- a map, a phone number, or even the distance to your business — so people can find you when they’re searching near you on relevant terms.

How to create ad extensions

Automated extensions
AdWords automatically creates and displays automated extensions such as seller ratings, consumer ratings, and previous visits when it predicts that they’ll improve your ad’s performance. No setup needed!
Manual extensions
You’ll need to manually create certain extensions such as apps, call, and location. You just fill out the information you’d like to include depending on the extension you choose. For example, if you’re creating a call extension, you add the phone number.

Create effective text ads

Text ad

1.Headline
People are most likely to notice your headline text. Consider including at least one of your keywords in the headline to make the ad even more relevant to the customer's search.
What’s new:
  • Updated to include two headline fields up to 30 characters each. You now have twice the opportunity to grab users’ attention.
  • Look out for how your longer headline — combined via a hyphen — might wrap on mobile devices.

2.URL
The URL shows your website address. It gives people an idea of where they'll go when they click your ad.

3."Path" fields(optional)
New to expanded text ads are two optional “path” fields, which can hold up to 15 characters. Part of your display URL, they are placed after your website’s domain to give readers an idea of the content they’ll see upon clicking your ad.

4.Description
Use the description to highlight unique details about your product or service. Be sure to include keywords that match probable search terms. On mobile, where space is tight, AdWords optimizes your ad to show the highest performing text.

The next generation of text ads: The expanded text ad

In our mobile-first world, it was inevitable that the text ad would evolve. Welcome, to the next generation of text ad, the expanded text ad, a format that is optimized for the mobile experience. Expanded text ads:

  • Provide advertisers more control of messaging
  • Offer users more information up front, before that first click

When you take a look at the two formats side by side, can you see why we call it “expanded”?

Writing effective text ads: five tips

To effectively reach potential customers, your text ads should be specific, relevant, attractive, and empowering. Let’s take a closer look at things to keep in mind when writing text ads. 
1. Highline what makes you unique
Show customers what makes you stand out from the competition.
2.Use a call to action
Use your descriptions to tell customers what they can do on your site once they click your ad — link them right to where the ad matters. 
3. Include sales terms
If you have a sale, make sure they know. Say it right in the ad.
4. Match your ad to your keywords
What might customers be thinking when searching for your products or services? Include those search words as keywords in your ad text.
5. Match your ad to your landing page
Ensure your ad takes customers right where they can act on it. The easier it is to find, the more likely they are to purchase.

How to make good on the new expanded text ad

With almost 50 percent more ad text available and an additional headline, expanded text ads provide even more opportunity for you to connect with users and drive more, qualified clicks to your website — if you use them wisely. Let’s see how to make good use of that extra space.
1.Rethink the messaging of your ad
2.Optimize your headlines
3.Take advantage of your character limits
4.Think about your mobile audience
5.Use ad extensions
6.Improve the landing page experience

Five tips to improve landing page experience

Offer relevant, useful, and original content
   • Make your landing page directly relevant to your ad text and keyword
  •  Be specific when the user wants a particular thing. If someone clicks on an ad for a sports car, they shouldn’t wind up on a general “all car models and makes” page.
  •  Be general when the user wants options. If someone’s looking to compare digital cameras, they probably don’t want to land on a specific model’s page.
  • Provide specific information on your landing page about whatever you're advertising.
  • Strive to offer useful features or content that are unique to your site.

Promote transparency and foster trustworthiness on your site
  •  Openly share information about your business and clearly state what your business does.
  • Explain your products or services before asking visitors to fill out forms.
  •  Make it easy for visitors to find your contact information.
  •  If you request personal information from customers, make it clear why you're asking for it and what you'll do with it.
  • Distinguish sponsored links, like ads, from the rest of your website’s content.

Make mobile and computer navigation easy
  • Organize and design your page well, so people don’t have to hunt around for information.
  • Make it quick and easy for people to order the product mentioned in your ad.
  • Avoid pop-ups or other features that interfere with their navigation of your site.
  • Help customers find what they’re looking for by prioritizing above-the-fold content.

Be fast — decrease your landing page loading time
  • Make sure your landing page loads quickly once someone clicks on your ad, whether on a computer or mobile device.

Make your site (even more) mobile-friendly
  • See how your site scores on mobile-friendliness and speed, and find out how to improve it. Test how mobile-friendly your site is with the link in our recap section at the end of this course.
  • See our guide in the recap section to learn more about how to create an effective mobile site.(https://testmysite.thinkwithgoogle.com/)

Choose where customers see your ads

Google Network


1. On the Search Network, your ads may appear on:
(1) Google Search, Google Shopping, Google Maps, and Google Play.
(2) Search sites that partner with Google.
2.On the Display Network, your ads may appear on:
(1) Google sites like YouTube, Blogger, and Gmail.
(2) Partnering websites across the Internet.

Ad formats

Text ads

The most common kind of Search ad includes a descriptive headline, website URL, and descriptive text like a call-to-action.

Where they can show:

Search Network

Display Network

Search partners

Ads with extensions

Ad extensions provide additional information to your text ad, such as your business’s address or phone number.

Where they can show:
Search Network
Display Network (depending on the extension)

Shopping ads

In addition to an image, shopping ads contain product and pricing information, so users get a strong sense of the product you're selling before they click your ad. They’re ideal if you’re managing a large inventory of products.

Where they can show:
Search Network

Image ads

Image ads capture people's attention as they browse websites in the Google Display Network.

Where they can show:
Search Network*
Display Network

*Image ads show on search partner networks, but not the Google Search Network.


Video ads

Video ads are just what they sound like — a standalone video ad or a video ad that runs inside another streaming video.

Where they can show:
Search Network*
Display Network

*Video ads show on search partner networks, but not the Google Search Network.

App promotion ads

App promotion ads send your customers to an app store to download your app, or include a deep link directly into your app.

Where they can show:

Search Network
Display Network

Call-only ads

Call-only ads allow your customers to call your business directly by clicking on your ad. They’re useful for driving phone calls to your business from devices that can make calls.

Where they can show:
Search Network

Rich media ads

Rich media ads are engaging ad formats that often include animation or other types of motion.

Where they can show:
Display Network


Responsive ads

The Display Network offers ads that adjust to match the pages and apps that show them. Viewers are more likely to see these ads because they blend in with the content the viewers came for. Responsive ads can go a long way to help build awareness, influence consideration, and drive action.

Where they can show:

Display Network

Improve results with experiments

Goals:
1.How to use drafts to stage changes to your campaign
2. How to run an experiment
3. How to measure your results

How campaign drafts work
Drafts let you prepare and review multiple changes to an existing campaign before implementing them.

How campaign experiments work
After you’ve finished a draft, instead of applying your changes to your original campaign, you can convert your draft into an experiment.




Evaluate campaign performance

Goal:
How to use reports and metrics to address your campaign objectives

Drive performance with reports
1.The Search terms report lists the searches and terms that triggered your ad and drove traffic to your website. If a term is getting you in front of customers, add it to your keyword list.

2.The Where your users were (user locations) report shows only your customers' physical locations (regardless of any locations they may have shown interest in). If customers in a certain region are gravitating to you, update your campaign to directly target them. 
3.The What triggered your ad (geographic) report shows your customers' physical locations and locations they had shown interest in through searches or content they had viewed. If customers interested in certain locations are finding you, update your campaign to directly offer something they’re looking for. 
4.The Landing page experience report estimates the quality of your landing page -- which is part of your AdWords quality score and strengthens or weakens your ad position. If you have a weak landing page, a link is provided with tips to make it better. 
5. The paid and organic report shows how people got to you — comparing Google’s free organic search results to your paid AdWords ads. Learn the ways customers are looking for products and services like yours and update your own keyword list or create new ad groups to directly target them. 
6. Once you've set up conversion tracking, attribution reports show you the paths customers took to complete a conversion, and attribute the conversion to different ads, clicks, and factors along the way.
Return on investment (ROI) tells you how effective your ad spend is by showing you how much return it’s bringing you. ROI is calculated with this formula: (Revenue-Cost)/Cost.

Example: If your ad resulted in $1200 of sales for a product that cost $600 to make, and your advertising cost was $200, then your ROI is [$1200 - ($600 + $200)] / ($600 + $200) = 50% ROI.

Align your budget with your goals

Goals:
1.How to determine the right daily spend for your ad campaign
2. How to align and revise your budget to support your campaign objectives

Tips:
1. Based on your monthly budget
If you're used to working with a monthly advertising budget, you can calculate the amount you might budget per day by dividing your monthly budget by 30.4 – the average number of days per month.
2. Based on your average cost-per-click
For example, let's say your cost-per-click is $0.10 on average, and you'd like around 500 clicks per day. You might budget $50 per day.
3. Based on impact factors
* Recent campaign performance
Current campaign budget
Keyword list
Campaign targeting settings

AdWords won't display a recommended daily budget if you rarely meet your daily budget, or if your campaign has limited data. 
4. Based on delivery method

When your average daily budget is reached, your ads will typically stop showing for that day. You'll want to consider your campaign's ad delivery method, which determines how quickly your ads are shown and how long your budget lasts during a given day, when setting your daily budget.

The "Standard" delivery method is like a slow-burning candle – it spreads your budget throughout the day.

The "Accelerated" delivery method is more like jet fuel – it uses your budget more quickly. 


Budget strategy for your goals: break down into three phases
1.Build awareness
Building awareness will require a larger budget due to the longer path to conversion and the scale at which you try to reach people. 
2.Influence consideration
Influencing consideration is mid funnel and can be accomplished with a small, medium, and large ad budget. With a medium length path to conversion, a medium to large budget is preferred so you can reach a wider group of people and begin moving them to action. 
3.Driving action
Driving action or sales is at the bottom of the marketing funnel where you typically have a small group of your target audience. You can meet all of your action goals with a small, medium, or large daily budget. 














Adjust bids to favor performers

Goal:

Bid higher for impressions that are likely to be more valuable, bid lower for impressions that are not.

Bid adjustment type:

1.Mobile: Use mobile bid adjustments to show your ad more or less frequently for searches that occur on mobile devices. 
2.Location: Use location bid adjustments to show your ad more or less frequently to customers in certain countries, cities, or other geographic areas.
3.Time of day: Use ad scheduling bid adjustments to increase or decrease your bids on certain days or during certain hours.
4. Top Content: Use bid adjustments for popular content to increase your ad’s chance of showing on top content on YouTube and the Display Network. When your ad is eligible to appear on this content, AdWords will use your bid adjustment to raise your bid.
5. Targeting methods: Use bid adjustments for topics, placements, and other targeting methods in campaign types that show ads on the Display Network.
6. Remarketing lists for search ads: Use bid adjustments for remarketing lists in your ad groups if you’d like to show ads more or less frequently to people on these lists.

Manage automate bidding

When to use automate bidding
1. Conversion tracking or Google Analytics is enabled
2.Advertiser is Adwords certified
3.Campaign has sufficient click and conversion data for algorithm to operate
4. Managing  campaign at scale
5. Have had 50-100 conversions over 30 days in a single campaign
6. Optimizing an existing campaign
Choose your automated bidding strategy
1.Ad clicks: Maximize clicks automatically sets your bids to help get as many clicks as possible within your budget. It can increase site visits and increase clicks on low-traffic terms. 
2. Ad visibility:
Target search page location: automatically sets your bids to help increase the chances that your ads appear at the top of the page or on the first page of search results.
Target outranking share: automatically sets your bid to outrank other domains in search results pages.
3. Ad conversions
Target cost per acquisition(CPA): automatically sets bids to help get as many conversions as possible at the target CPA you set. (Some conversions may cost more or less than your target).
Enhanced cost per click: automatically adjusts your manual bids to try to maximize conversions. This strategy helps increase conversions while letting you stay in control of your keyword bids. 
4. Ad revenue
Target return on ad spend (ROAS) bids more where AdWords estimates ads are more likely to lead to a sale, aiming to get as much ROAS as possible. 

Friday, June 23, 2017

Mange manual bidding

When to use manual bidding:
1.Small budget
2. Wants more budget control
3. Reworking an underperforming campaign
 How to choose your manual bidding strategy?
1. CPC: Ad clicks and conversions
2.CPV: Ad views
3. vCPM: Ad reach
4.CPE: Ad engagement

Best Practice:
1.Use conversion tracking or Google Analytics
2.Decide bid amount with data: Keywords Planner
3. Based on your goal
4. Optimize your bids: Review your account data to identify your most profitable keywords, devices, and locations and set bid adjustments to boost to these bids.

Determine a good bidding strategy

Considerations:
Overall budget
Campaign goals
The value of a sale or conversion

Process:Good bidding-> place in auction-> being show

Two Ways:
Manual bidding
Automated bidding

Goals decide your bidding strategy
1.Build awareness: vCPM or CPV, focusing on impressions.
2. Drive web visits: Focusing on clicks. CPC
3. Drive online sales: Focusing on conversions. CPA

3 tools to determine your CPC bids:
Bid simulator
Keyword Planner
First-Page bid estimates

Match media cost models with your budget

Cost Models:
CPM: Cost per thousand impressions-> want to raise brand awareness
vCPM: Viewable Cost Per Thousand Impressions-> want to raise brand awareness but only pay for impressions measured as viewable
CPC: Cost Per Click-> Drive traffic to my site
CPV: Cost Per View-> want to increase video views
CPA: Cost Per Acquisition-> want to increase sales

Wednesday, June 21, 2017

Readiness Check failing due to Cron script readiness check failed

I went into {magento-directory}/setup/src/Magento/Setup/Controller/Environment.php
around Line 194
i commented out :
 //$setupCheck = $this->cronScriptReadinessCheck->checkSetup();
 //$updaterCheck = $this->cronScriptReadinessCheck->checkUpdater();
and replaced it with :
$setupCheck = ['success' => 1];
$updaterCheck = ['success' => 1];
this just skips the Cron check altogether.

Tuesday, June 20, 2017

Angular 2 Pipe


@angular/common

  • AsyncPipe
  • CurrencyPipe
  • DatePipe
  • DecimalPipe
  • I18nPluralPipe
  • I18nSelectPipe
  • JasonPipe
  • LowerCasePipe
  • PercentPipe
  • SlicePipe
  • TitleCasePipe
  • UpperCasePipe
自定义Pipe

Angular 2 component life cycle

1.OnInit
2.AfterContentInit
3.AfterViewInit
4.OnChanges
5.DoCheck
6.AfterContentChecked
7.AfterViewChecked
8.OnDestroy


Relationship:

Monday, June 19, 2017

Angular 2 DI


  • 每一个HTML 标签上都会有一个注射器实例
  • 注射是通过constructor 进行的
  • @Injectable 是@Component 的子类

它也是一个树形结构

Angular 2 Technical Map


Sunday, June 18, 2017

The ngModule of Angular 2

Component

Encapsulates the template, data and the behavior of a view

Communication:
  • @Input: Parent component to Child component
  • @Output:Child component to Parent component
  • Use Service


Service

Data access
Logging
Business Logic
Configuration

Router

Responsible for routing rules.


Directive

To modify DOM elements and/or extend their behavior.

What Angular 2 offers


  1. Dynamic HTML
  2. Powerful templates
  3. Fast rendering
  4. HTTP services
  5. Component encapsulation
  6. Form & input handling
  7. Event handling
  8. Routing
  9. Latest JavaScript standards


What's new from Angular 1:


  • No more controllers and scope
  • Components /reusable code
  • Reduced learning curve
  • TypeScript & ES2015/ES6
  • Better mobile support
  • RxJS & Observables



What is TypeScript


  • A strict superset of JavaScript with added features
  • Maintained by Microsoft
  • Optional static typing
  • Class-based object-oriented programming
  • Resembles languages like Java and C/C++


Components is the main way to build and specify elements and logic on the page


  • Basic building block of the UI. An Angular application is a tree of Angular components.
  • Decorators allow us to mark a class as an Angular component & provide metadata that determines how the component should be processed, instantiated and used at runtime.


Services:


  • Services are used for reusable services to share between components throughout an application.
  • Refactoring data access to a separate service keeps the component lean and focused on supporting the view
  • Services are invariably asynchronous. We can return data as a promise or an observable using RxJS.

Angular 2 Installation Methods

  • From scratch
  • Using the quickstart https://github.com/angular/quickstart
  • Angular-CLI Tool: npm install -g angular-cli
  • Requirements:Node.js, NPM, Git


MongoDB Commands on Windows

1.cd mongodb\bin
2.mongod --directoryperdb --dbpath c:\mongodb\data\db --logpath c:\mongodb\log\mongo.log -- logappend --rest --install
3.net start MongoDB
4.mongo
5.show dbs
6.use mycustomers
7.db
8.db.createUser(
   {
     user: "accountUser",
     pwd: "password",
     roles: [ "readWrite", "dbAdmin" ]
   }
)
9. db.createCollection("customers");
10.show collections
11. db.customers.insert({first_name:"John", last_name:"Doe"});
12.db.customers.find();
13.db.customers.insert([{first_name:"John", last_name:"Johnson", gender:"female"},{first_name:"Steven", last_name:"Smith"}]);
14.db.customers.find().pretty();
15.db.customers.update({first_name:"John"},{first_name:"John", last_name:"Doe", gender:"Male"});
16.db.customers.update({first_name:"Steven"},{$set:{gender:"male"}});
17.sb.customers.update({first_name:"Steven"},{$set:{age:45}});
18.db.customers.update({first_name:"Steven"},{$inc:{age:5}});
19.db.customers.update({first_name:"Steven"},{$unset:{age:1}});
20.db.customers.update({first_name:"Mary"},{first_name:"Mary", last_name:"Samson"},{upsert:true});// if Mary not exist, insert into db;
21.db.customers.update({first_name:"Steven"},{$rename:{"gender":"sex"}});
22.db.customers.remove({first_name:"Steven"});
23.db.customers.remove({first_name:"Steven"},{justOne:true});
24.db.customers.find({first_name:"Sherron"});
25.db.customers.find({$or:[{first_name:"Sherron"},{first_name:"Steven"}]});
26.db.customers.find({gender:"male"});
27.db.customers.find({age:{$lt:40}});
28.db.customers.find({"address.city":"Boston"});
29.db.customers.find({memberships:"mem1"});//find array elements
30.db.customers.find().sort({last_name:1});//ascending order
31.db.customers.find().count();
32.db.customers.find(gender:"male").count();
33.db.customers.find().limit(4);
34.db.customers.find().limit(4).sort({last_name:1});
35.db.customers.find().forEach(function(doc){print("Customer Name:"+doc.first_name)});





Thursday, June 15, 2017

树状结构编程队伍

1.任务
2.产品负责人
3.技术主管和结构师
4.进度
5.人力划分
6.各部分之间的接口定义

Wednesday, June 14, 2017

How to Setup Magento with Multiple Stores and Domains

One of the useful features in Magento is the ability to create multiple stores/websites that share the same Magento installation. This allows multiple store fronts to share a common code base and backend, making administration a lot easier. Stores can share customer base, product catalog and settings based on how you choose to configure your sites.
This tutorial will go through the steps of setting up multiple stores in Magento, and how to configure a domain for each store.

Prerequisites

  • Magento must be installed
  • Access to add new vhosts (virtual hosts). Most control panels (like cPanel) supports this.

URL structure

Before you start adding new stores to Magento, you should have a clear understanding of how each store will be addressed, i.e. how the URL will look like. You basically have three approaches:
  • Domain (e.g. www.store1.com and www.store2.com)
  • Subdomain (e.g. store1.mystore.com and store2.mystore.com)
  • Folder (e.g. mystore.com/store1/ and mystore.com/store2/)
How you choose to structure your stores is a matter of personal preference, and the steps for setting this up will be more or less the same. Generally, subdomains are often used to create localized or area-specific versions of the store (e.g. es.mybestshop.com and en.mybestshop.com). Since most users will choose either the domain or subdomain method, this is the method I will describe in this tutorial.

Server configuration

Before we create the new Magento stores, we need to configure each domain/subdomain to resolve to the same Magento installation. That is, the document root of each virtual host must be set to the file path where Magento is installed. How this is done depends on the web server and control panel. For this example, we are assuming the server is running the Apache Web Server and the cPanel control panel. The method will be relatively similar for other control panels.
Assuming your main domain is already set up in cPanel, we just need to add the additional domains/subdomains. We will use the Parked Domains feature in cPanel to add the additional domains. Parked domains are similar to aliases, so they will automatically resolve to the same file directory. If you chose the subdomain method, just create the subdomains and point them to the directory where Magento is installed.
Parked Domains Parked Domain in cPanel

Add new Magento store

The next step is to create the actual stores in Magento. Lets say we want to add a new store mysecondstore.com.

Create root category

If you want your websites to share the same catalog and categories you can skip this step.
  1. Log into your Magento Admin Panel
  2. Click on Catalog Manage Categories
    magento-categories
  3. Click on Add Root Categorymagento-root-catalog
  4. Enter a name for the new category and make sure Is Active is set to True
  5. Click on the Display Settings tab and set Is Anchor to True. This will show products listed in sub categories, and also enable product drill-down functionality (filtering) for the category.
    magento-category-anchor
  6. Click Save Category

Store configuration

Before we start configuring our stores, lets pause for a minute and explain the concepts of Websites, Stores, and Store Views in Magento. Websites are the top-most entity in Magento. If you want completely separate sites that do not share cart, shipping methods, etc., you should create separate Websites. Each Website has at least one Store, and each Store has at least one Store View. Multiple Stores can share cart, user sessions, payment gateways, etc., but have their own catalog structure. Finally, a Store is a collection of Store Views. Store Views change the way pages are presented, normally used to offer a site in different layouts or languages. These concepts can be a bit confusing at first and I recommend this webinar which explains the Magento multi-store retailing in detail.
  1. Go to System > Manage Stores
  2. Click Create Website and enter the following information:
    (Skip this step if you don't want separate Websites)
    • Name - enter a name for the new website
    • Code - enter a unique identifier for this website
      Make a note of this code as you will need it later!
    magento-create-website
  3. Click Create Store and enter the following:
    • Website select the website you just created from the dropdown;
    • Name - enter a name for the store;
    • Root Category - select the category you created in the previous step.
    magento-add-store
  4. Click Create Store View and the information as follows
    • Store - select the store you created in the previous step
    • Name - enter a name for the store view
    • Code - enter a unique identifier for this store view
      Make a note of this code as you will need it later!
    This is where you will add additional store views if you plan on setting up a site for each language you support for example.
    magento-add-storeview
  5. Now, go to System > Configuration > General
  6. Make sure Default Config is selected as the Current Configuration Scope
    magento-config-scope
  7. On the Web tab, set Auto-redirect to Base URL to No and click Save Config
    magento-web-settings
  8. Now, change the Configuration Scope dropdown to you newly created website
  9. Under the Web section, we now need to change the Secure Base URL and Unsecure Base URL settings. Uncheck the Use Default [STORE VIEW], and replace the URL's with your corresponding domain name. Remember to include the trailing /.
    magento-site-urls
  10. Click Save Configuration
This completes the configuration of the new store. Repeat these steps for each additional store you want to add.

Domain mapping

So far we have added the additional domains to the server and configured the new store in Magento. Now we just need to glue it together by telling Magento which store to load based on the domain name the user is on.
  1. On the server, open the .htaccess file, located in the root directory of your Magento installation, in your favorite text editor. You can also use the File Manager in your control panel.
  2. Add the following lines (replace with actual domain names):
    
    SetEnvIf Host www\.domain1\.com MAGE_RUN_CODE=domain1_com
    SetEnvIf Host www\.domain1\.com MAGE_RUN_TYPE=website
    SetEnvIf Host ^domain1\.com MAGE_RUN_CODE=domain1_com
    SetEnvIf Host ^domain1\.com MAGE_RUN_TYPE=website
    
    SetEnvIf Host www\.domain2\.com MAGE_RUN_CODE=domain2_com
    SetEnvIf Host www\.domain2\.com MAGE_RUN_TYPE=website
    SetEnvIf Host ^domain2\.com MAGE_RUN_CODE=domain2_com
    SetEnvIf Host ^domain2\.com MAGE_RUN_TYPE=website
    
    ...
    Note: the SetEnvIf directive is not supported by all web servers (e.g. LiteSpeed). In that case, the store code can be set in this way:
    
    RewriteCond %{HTTP_HOST} www\.domain1\.com [NC]
    RewriteRule .* - [E=MAGE_RUN_CODE:domain1_com]
    RewriteCond %{HTTP_HOST} www\.domain1\.com [NC]
    RewriteRule .* - [E=MAGE_RUN_TYPE:website]
    
    RewriteCond %{HTTP_HOST} www\.domain2\.com [NC]
    RewriteRule .* - [E=MAGE_RUN_CODE:domain2_com]
    RewriteCond %{HTTP_HOST} www\.domain2\.com [NC]
    RewriteRule .* - [E=MAGE_RUN_TYPE:website]
    
    
    • MAGE_RUN_CODE - this is the unique code chosen when you created the Magento Website / Store View
    • MAGE_RUN_TYPE - depending on whether you want to load a specific Website or Store View; set it to website or store, respectively.
    Add an entry for each additional domain you have set up.
  3. Save the file
Now navigate to you new site and verify that the correct Magento store is loaded. If not, make sure that the the MAGE_RUN_CODE match the one created earlier and that the domain resolves to the correct folder/path.

Note about Magento versions prior to 1.4

The ability to set store code using environmental variables were introduced in Magento 1.4. If you are running an older version of Magento, or your webserver does not support Apache environmental variables, you must set the store code using a different method.
  1. Open index.php in any text editor
  2. Look for the following line near the bottom of the file:
    Mage::run($mageRunCode, $mageRunType);
  3. Add the following lines right above this line:
    switch($_SERVER['HTTP_HOST']) {
        case 'domain1.com':
        case 'www.domain1.com':
            $mageRunCode = 'domain1_com';
            $mageRunType = 'website';
        break;
        case 'domain2.com':
        case 'www.domain2.com':
            $mageRunCode = 'domain2_com';
            $mageRunType = 'website';
        break;
    }
    Replace the domaincode and type according to your particular setup. Add additional case statements if you have more stores.
  4. Save the file
Reference:
https://www.properhost.com/support/kb/30/How-To-Setup-Magento-With-Multiple-Stores-And-Domains