Thursday, April 21, 2011

How to install Magento on Local server without url validation error


How To Install Magento On Localhost Without URL Validation Error

Do You Like This Story?

If you have ever tried to set-up a localhost install of the Magento e-Commerce system for development purposes using WAMP, XAMPP you may have already run into the problem of URL / Domain validation halting the install process due to using localhost as the domain. This tutorial will explain how to successfully install Magento on you PC hosted localhost server.

The image above shows the error you will receive when trying to install Magento on a PC running WAMP, XAMPP etc. The error happens because Magento tries to validate the domain name under which you install the Magento system, when you use http://localhost as your domain Magento halts the install process completely. This can be a really annoying fact that stops a lot of people installing Magento on their home PC to evaluate it before committing to the system for there e-Commerce project. The short tutorial below will show you how to bypass this particular install error and successfully install Magento on your localhost test machine.
Firstly you will need to edit a Magento file to acheive this technique, it’s pretty easy to do so anyone should be able to follow this tutorial but if your not confident editing a file get a friend who is to do it for you. To edit any files we recommend that you use PSpad which is a text editor specifically built for editing php, javascript files etc.
1) Open you Magento folder and go to the directory /js/prototype/
2) You will see a file titled validation.js, open this file in your text editor.
3) Look for the code between lines 505 to 507, it should look like the code snippet below.
1
2
3
['validate-url', 'Please enter a valid URL. Protocol is required (http://, https:// or ftp://)', function (v) {
                return Validation.get('IsEmpty').test(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
            }],
4) now you want to comment out those three lines of code by typing // in front of each of them, the code snippet below gives an exact example of what you should end up with after the edits. These edits disable only those three lines of code which check for a valid domain name upon Magento installation.
1
2
3
//['validate-url', 'Please enter a valid URL. Protocol is required (http://, https:// or ftp://)', function (v) {
                //return Validation.get('IsEmpty').test(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
            //}],
5) Install Magneto on your localhost, after install has completed successfully revert the validation.js file to it’s original code by removing the instances of // you added.
You should now have a fully functional install of Magento on your WAMP, XAMPP install on your home PC or business development server. If you have any questions about this technique please leave a comment.

No comments:

Post a Comment