Enable cURL with XAMPP

cURL is disabled by default in your XAMPP installation. To enable it, you have to modify the php.ini files in your XAMPP folder. Follow the steps below to get it up and running.

  1. Locate the following files:
  2. Uncomment the following line on your php.ini file by removing the semicolon.
  3. Restart your Apache server.
  4. Check your phpinfo if curl was properly enabled.

How to setup a local web server on your computer using XAMPP

Web development work should always be done locally. When developing a website, all the development work should be done on a local LAMP Stack environment installed on your computer. That way, the production time is greatly reduced and you can fully test your work before launching.

When you are completely done developing your project, the migration to the live server is seamless. Here are the simple steps to install a local server on your PC to easily develop websites.

This article applies to the installation on Windows 98, NT, 2000, 2003, XP and Vista, of Apache, MySQL, PHP + PEAR, Perl, mod_php, mod_perl, mod_ssl, OpenSSL, phpMyAdmin, Webalizer, Mercury Mail Transport System for Win32 and NetWare Systems v3.32, Ming, JpGraph, FileZilla FTP Server, mcrypt, eAccelerator, SQLite, and WEB-DAV + mod_auth_mysql.

Installing XAMPP on your computer

  1. First, download XAMPP for Windows Installer
  2. Then run the installer on your computer and make sure that your Windows firewall unblocks Apache.
  3. Run the Apache administrator.
  4. Open your browser and go to http://127.0.0.1 – If all went well, a screen will appear where you can choose your language.
  5. Go to http://127.0.0.1/security/xamppsecurity.php and setup a password (it ill be used for your databases), and click on “Password Changing”.

Congratulations! You’re done! Now put your website’s files in a new directory under C:\xampp\htdocs\ (if you installed xampp in C:\xampp). For example: C:\xampp\htdocs\myproject\; and setup your databases using PHPMyAdmin located here http://127.0.0.1/phpmyadmin/.

Configuring Mod Rewrite

To finalize your installation, and make your development work much easier, go through the following steps to enable Mod Rewrite. This enables you to use fancy permalinks without the index.php appendage.

  1. Navigate to C:\xampp\apache\conf\httpd.conf
  2. Open up httpd.conf in notepad and look for this line:
  3. Uncomment it so that it reads:
  4. Next, search for AllowOverride None and change it to AllowOverride All.
  5. Restart Apache by typing services.msc in either the command prompt or Start Search prompt in Vista.

Personalized Domain for your Local Environment

I’ve set my local environment to mimic my live environment as much as possible. For example, to access the local environment for my blog, I type this in my browser (http://www.richardcastera.com). Here is how to set that up for each project:

  1. Navigate to C:\Windows\System32\drivers\etc\ and open the host file in a notepad editor. Make sure the following lines are written in the file:
  2. Now add the following line to access your website locally via the URL myproject.dev (or any other URL you’d like):
  3. Finally, open the file C:\xampp\apache\conf\extra\httpd-vhosts.conf in a notepad editor, and add the following lines:

That’s it! Hope you enjoyed the post!

How to Create a Custom 404 Error page with .htaccess

Everyone’s encountered those standard 404 error pages that yield little or no information. Most new systems have this feature built in by default and often times are pretty fancy with informative to funny graphics and lots of options on what to do next but, if your working on updating an old site not using dynamically based web pages then, your going to have to add one manually. For your user’s experience, it’s better to provide a helpful error message and links to where they can continue on their quest for information. You don’t want to scare your visitors away do you? Here’s how to add your own custom 404 error page to your website:

If you don’t already have an .htaccess file in your servers root, go ahead and create one. Now you need to instruct .htaccess where your custom error page is. In this example, I have the 404 document which I created with my editor that provides lots of useful information for users to continue browsing my site. Now add this line to your .htaccess file and that’s it!

 

Disallow hotlinking while allowing requests from robots.txt and favicons

We all hate Leechers. Here’s how to stop them in their tracks from stealing your images and your bandwidth!

 

Creating an .htaccess file on Windows

Everyone who has tried creating a .htaccess on windows knows that Windows Explorer does not accept the ‘.’ character as the first character of a file. For most of you this may be old stuff, but for the newbies, the quick way to create a file that starts with a ‘.’ is actually pretty simple.

Open notepad and save the document with file name .htaccess with the ‘save as type’ set to ‘All Files’; or save the document with file name as “.htaccess” including the quotes. Hope this helps someone!

htaccess – How to redirect all http (port 80) requests to https (port 443)

Sometimes you may need to redirect http requests on port 80 to (https) on port 443. This can easily be accomplished with .htaccess.

 

Using SSH and Unix commands

Having some basic knowledge of SSH and Unix commands is very useful. Developed in 1995, SSH (Secure Shell) was created as a secure alternative to Telnet. Telnet is a protocol allowing for command line access to a Unix, Linux or FreeBSD based remote computer. I’ve listed some basic commands to get you familiar with them.

The cd command is used to move to a specific directory.

The cp command will copy the file or folder from the source, to the destination.

mkdir creates a directory.

The rmdir command deletes a directory.

The rm command deletes a file.

The mv command will rename or move a file stated in the first portion to the name or location stated in the second portion.

This command will tar zip the files in the directory specified in the second portion into a tar file specified in the first portion.

The tar -xvf will extract all files from the tarball specified into the directory you are currently in.

This will create a zip file, with the name specified in the first portion from the file or directory listed in the second portion.

This command will unzip or un pack the named zip file, into the directory you’re currently in.

The Ls command lists files, and folders within the directory you specify

This will add a forward slash to the directory names within the directory you specify

This will show “hidden” files in the directory you specify

This command shows detailed info about each file in the directory you specify.

Also, a lightweight, freeware application which supports SSH commands for windows is PuTTY if you aren’t on a MAC.

.htaccess – Limit website access by IP

I’ve been asked many times how to limit website access by allowable IP’s. This is fairly simple to accomplish with .htaccess and very useful for blocking web vagrants to allowing you to make updates to a website while redirecting all other IP’s to a maintenance page. Simply follow the steps below:

  1. Create a file and name it .htaccess.
  2. Add The following to the file:

     
  3. Replace 255.255.255.255 with you IP address. (If you don’t know it, you can get it here: WhatsMyIP)
  4. Once the file is created, put it in the root directory. That’s it!

Adding 301 Redirects using htaccess

It’s easy adding 301 redirects to your website using Apache’s htaccess. A 301 redirect is the most efficient and Search Engine Friendly method for web page redirection. It’s not difficult to implement and will preserve your search engine rankings as well.

Often when someone does a redesign of their website or puts it into a new platform, and little consideration is regarded for the difference between the existing an new link structure. You should have a redirect in place if your old link structure varies from the new one. This will help you maintain you search engine rankings and decrease the possibility if someone reaching a 404 page.

Below is one variant of a 301 that redirects when someone tries to access your website without the (www); It will redirect the URL to your website with the www. You should choose which variation your website should stick with because accessing your website both ways is bad for Search Engine Optimization.

So, to implement this type of redirect for your website, follow these instructions:

  1. Open up notepad or any other text editor and copy and paste the commands below.
  2. Change (yourdomain) to your domain name.
  3. Save the file with this name: (.htaccess). There is no file name. If you have a problem doing this on Windows, read this article.
  4. Upload it to the root directory of your website.