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

user1712189 picture user1712189 · Oct 5, 2012 · Viewed 17.6k times · Source

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

Answer

philwinkle picture philwinkle · Oct 5, 2012

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