Magento - Create different store view (languages) on the same domain - .htaccess

I create more store views in my Magento 1.9 store, how I can add a subdomain per each store view.
For example I create a new store with the name eu where I setup the language to be english and I need to add a subdomain for this store view: eu.example.com but my url is something like this: http://example.com/?___store=de&___from_store=eu.
I made the steps like in this image, what I need to do to have this subdomain: eu.example.com to the eu store view?
Also I try to add something like this in .htaccess without success:
RewriteCond %{HTTP_HOST} ^eu.example.com
RewriteRule ^ - [E=MAGE_RUN_CODE:eu]

You have to add this in your vhost file :
SetEnvIf Host ".*eu.*" MAGE_RUN_CODE=eu MAGE_RUN_TYPE=store

No Need to change htaccess just need to manage the subdomain
Follow this steps:
change the secure/unsecure url for associated store
Configure Subdomain/If you are using Local Machine then assign virtual host with same directory
Just run the site it's working well

Related

Fake subdomain for different users while still browsing same folder structure

I'd like to create fake subdomains for different users for more vanity, and to make the user (in this case a company) feel they are in a more isolated environment.
For the sake of maintainability, it's important for me that all users still browse the same files, to avoid having to update files for every single user that exists when updating the code.
My website has one public part at root, let's say www.example.com. I'd like to be able to fake the following kind of subdomains:
user1.example.com
The true URL would be www.example.com/member/?user=user1. I'd like for the folder structure to follow the same pattern. www.example.com/member/settings/?user=user1 would appear as user1.example.com/settings/ and so on.
I assume this would best be achieved with .htaccess, no?.
What is the proper .htaccess code for this?
Thank you!
based on the information you've provided here's a bit of .htaccess not tested but might do the job.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example.com$ [NC]
RewriteCond %{QUERY_STRING} ^user=(.*)$
RewriteRule ^(.*)$ http://%1.example.com/$2? [R=302,L]
Once you find it working fine, replace 302 to 301
Note: It's important to note that you'll need to add a subdomain wildcard
In the end, this was super easy to solve! It wasn't solved the way I first expected though, using .htaccess. I solved it with something called wildcard subdomain.
When you register a new subdomain, enter * in the domain prefix, such as *.example.com. A folder for the wildcard subdomain will be created on your server, such as _wildcard_.example.com. Whenever you access site1.example.com, fakesub.example.com etc, the browser of the visitor will read the files in the wildcard.example.com folder.
The beauty of it all is that if I create a certain subdomain that I want to use, for example forum.example.com, this real subdomain will have priority over the wildcard subdomain, and files will be fetched from the folder for this subdomain, as opposed to from the wildcard subdomain folder.
I use PHP and need to know the subdomain to fetch the appropriate database for the current user. To do this, I use the following code:
$subdomain = explode('.', $_SERVER['HTTP_HOST'])[0]
With a wildcard SSL cert I have all of these subdomains secure.

How do I keep my original domain in the URL bar when forwarding?

I own the domain portraittwo.co.uk - I also own portrait-london.co.uk - The later site currently has a hosting package attached and currently has a Wordpress installation running. I’ve installed a second installation at portrait-london.co.uk/wpinstall and I now want to forward the portraittwo.co.uk domain to /wpinstall on the second domain however I don’t want the domain in the URL box to change. Is this possible? If so how can I achieve this?
Note: On portraittwo.co.uk there is no hosting attached so I cannot edit .htaccess
This can be easily achieved if your host offers CPanel. In this case all you need to is add an addon domain portraittwo.co.uk and set its root directory to public_html/wpinstall. However, as I can see your host does not offer that and since you do not have hosting for portraittwo.co.uk and you do not have a valid DNS zone and a.htaccess file, I do not think that there is a way to do it.You can get a free hosting account for portraittwo.co.uk just for the sake of getting an .htaccess file and then set a rule :
RewriteCond %{HTTP_HOST} ^portraittwo.co.uk
RewriteRule ^(.*) http://portrait-london.co.uk/wpinstall [P]
This should do the trick.

Automatically change domain name in URLs

I'm creating a mirror for my website and I need to automatically change domain name in URLs on my new website, using some .htaccess command on my new site.
What I need is to change all links from www.old.com/any_link.html to www.new.com/any_link.html for all users on www.new.com without changing anything in database (having the same database for both sites). So that I get two independent websites www.old.com and www.new.com working at the same time.
I know about redirect 301 from old site to the new one, but I need redirecting INSIDE new website, without changing anything on the old one.
Is that possible at all?
try writing this on .htaccess :
RewriteEngine on
RewriteRule ^(.*)$ http://www.new.com/$1 [R=301,L]

How can I use different urls for different store views in magento?

I have different store views in my magento shop for different languages. I can access them through
www.serverdomain.from.my.hoster.tld/langkey/
The langkeys are the codes of the different store views and I enabled "add store code to urls".
Now, I want to use my following registered domains without editing index.php
www.myshopsite.langkey
for example:
www.myshopsite.de
www.myshopsite.en
www.myshopsite.com
For that I tried to set MAGE_RUN_CODE and MAGE_RUN_TYPE via htaccess till I realized that they are used to get different stores and not different store views.
Since I configured the base URL for my german store view I can access it via
www.myshopsite.de/de/
Now I am trying to internally redirect from www.myshopsite.de/ to www.myshopsite.de/de/ to remove the trailing store view code.
Thats my try which ended in a redirect to www.myshopsite.de/en/ and an internal server error
RewriteEngine on
RewriteRule ^$ de/$1 [L]
RewriteRule ^(.*) de/$1 [L]
I am sorry if my fault is obvious.
You can try this at the bottom of your .htaccess file located in your Magento root directory.
SetEnvIf Host www\.myshopsite.\.$ MAGE_RUN_CODE=$1
The MAGE_RUN_CODE variable is for the Magento Store View. You essentially set it to the store view code set under System > Manage Stores > Store View
I've done quite a bit of these configurations so I know that sometimes your server environment setup (apache etc) may differ, and using SetEnvIf in .htaccess may not work. If that is the case, you may be better off inserting a bit of code into the index.php that achieves the results you are looking for.
Yes, it's modifying a core file, however given this scenario is might be more stable to have PHP handle the store variable mapping rather than apache.

Retrieving files from another URL on the server

I have one server two domains. I need the images and css apply to both domains. Currently I solve it using htaccess:
RewriteRule ^.*\.(css)$ http://www.rs.cz/style/$0 [L,R]
How is it possible to improve? Or at least refer to a relative path on the server?
Create one subdomain just for hosting images and static content like:
images.mydomain1.com
and another subdomain like:
images.mydomain2.com
Have both of them redirect to the same directory in the server like /var/www/common_images.

Resources