Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Direct Magento installation path in subfolder to main domain name

I have installed Magento 1.7.0.2 to mydomain.com/mag

(mydomain - is the primary registered domain at my hosting account) (mag - is any subfolder)

As my website in testing mode, if anything goes wrong, i simply have to delete the “mag” folder and also it does not overwrite any files under public_html.

But if i install on directly to root directly public_html, then it may overwrite few files or folders and if i want to revert any time, then i cannot do that manually.

As i don’t even know the exact folder and file default structure under public_html prior to magento installation.

(I did that once by mistake, that happened)

Now at frontend the site URL will be mydomain.com/mag

But i want, if customers type the http://www.mydomain.com, they will be able to see the LIVE website instead of typing http://www.mydomain.com/mag

How do i do that

Also, will this be OK for SEO part.

Do we need to do this in Magento backend. or Do we need to do with hosting company by setting sub-domain type or By telling Simple scripts the installation to change the installation folder from mydomain.com/mag to www.mydomain.com

Please do suggest how can i do so.

Regards

like image 516
user1712189 Avatar asked Oct 05 '12 15:10

user1712189


People also ask

How do I point a domain to a subfolder?

Click on "Hosting" on the left side of the page under "My Products," then click on "Manage Account" and choose "Domain Management" under "Settings." Click "Add Domain." Enter the new domain name in the field marked "Domain," and enter the sub-folder that will contain the site in the "Folder" field.

Where is Magento installation directory?

In a standard installation with an Apache web server, Magento is installed to the default web root: /var/www/html/magento2 . Within the magento2 folder are: /pub/ /setup/


2 Answers

In System > Config > Web you will find the following settings for your 'base url'. To update this you will have to perform the following 3 steps:

Step 1: Set the default store to the proper base url

web configuration settings

Notice that the base url has the subfolder defined.

Step 2: Set your STORE VIEW base url to the root url

Using your dropdown on the left, change the "Current configuration scope" to your store view [NOT DEFAULT]

store view switcher

To change the base url value, uncheck 'use website' and enter your new base url:

new base url

Also, double-check in the same screen that your Session file management cookie path is set to the root folder of your site and that the domain is correct:

cookie management

Step 3 [also used for multiple store management]

Finally, and this is important, you need to copy the index.php file, .htaccess file, and symlink your media,skin and js folders to your root directory, because they're only available to your subfolder Magento base install right now - we need to let your main domain know where to look for Magento!

From secure shell in your Magento installation directory (in your case, mag) as sudoer:

sudo cp index.php ../
sudo cp .htaccess ../
sudo ln -s js ../
sudo ln -s skin ../
sudo ln -s media ../

Your admin will still be available at yoursite.com/mag/admin.

Edit your index.php file in this main webroot (the file you just copied) and update it around line 45:

$mageFilename = 'app/Mage.php';

Change this to :

$mageFilename = 'cart/app/Mage.php';

Where 'mag' is the subfolder. In your case you'd use the folder named 'mag'. Finally, you need to clear the cache for these changes to take effect.

Step 4: Multi-store [optional]

If you have more than one store, they can all be served this way, but you need to edit the index.php file to give it the correct store code. More info about that can be found here:

http://www.magentocommerce.com/knowledge-base/entry/overview-how-multiple-websites-stores-work

like image 124
philwinkle Avatar answered Nov 15 '22 11:11

philwinkle


i must say that figuring out how to symbolic link was a hassle and i still couldnt figure it out. All the other steps worked fine except i copied my htaccess and my index.php and i just pasted it to my root. So for those who are having trouble, i found a better solution instead of symbolic link for "media, skin and JS" folders. In your magento admin. System>config under general click web. just change your base skin, media and js to the folder you want them to point to...

ex: {{unsecure_base_url}}cart/skin/

worked for me. Hope it works for anyone with the same problem. Ohh and im using magento 1.8.1 Thanks again @philwinkle

like image 40
Art Avatar answered Nov 15 '22 11:11

Art