Jeremy Simkins | Web Developer

Aug
24

Simple PHP WWW redirect

Filed Under: php

With SEO being an important factor in wed design, it is recommended to use either WWW or non-WWW for your site URL; it is not wise to use both. This can easily be done by using .htaccess. There are situation when using .htaccess is not possible and the only means to do the redirect is by using PHP. I have recently found myself in this situation and I decided to post this simple code snippet that will redirect non-WWW URL’s to the WWW URL.
The code is:

// Check if we need to perform a redirect
$fetchedURL = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
if (substr($fetchedURL,0,4) != 'www.') { // Make sure the URL does not use www.
    // Let do the redirect
     header( "HTTP/1.1 301 Moved Permanently" );
     header('Location: http://www.'.$fetchedURL.((isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : '')); // Append the REQUEST_URI
}

The code is very simple and is documented. I hope some may be able to make use of this script.
The above code will take the provided URL and forward it to the WWW URL. This will retain the full URL path. I.E.: http://son9ne.com/index.php?somevar=somevalue will be changed to http://www.son9ne.com/index.php?somevar=somevalue

May
20

MAMP DB File Location

Filed Under: Mac, MAMP, php, Zend

I work on many sites and some of my databases are too large to upload with phpMyAdmin. One of the biggest issues I have had was trying to import a large database into MAMP or take a large database out of MAMP and put it live. Another problem is when I am changing computers or restoring my Mac it is much easier to use Time Machine and grab these files instead of having to create a backup and re-import them. After failing on many searches on Google I finally found out where MAMP stores the DB files.

The path you can find these files is:
/Library/Application Support/living-e/MAMP PRO/db/mysql
For the latest version of MAMP Pro (currently 1.8.1):
/Library/Application Support/appsolute/living-e/MAMP PRO/db/mysql

I assume that if you are running MAMP Pro, you would only need to amend the path to MAMP if not.

Jan
06

Removing .svn directories from a folder in Terminal

Filed Under: Mac

Well i was trying to find a way to remove all the .svn files from a directory on OSx.
I found this code worked the best for fully removing all .svn files recursively.

find . -name .svn -print0 | xargs -0 rm -rf

Remember to cd to the directory you are wanting to remove the .svn files from.

cd Sites/project

Sep
29

Setting up MAMP Pro with Zend Debugger, Optimizer and Extension Manager

Filed Under: MAMP, Zend

It seems some are having trouble setting up the Zend Debugger so i wrote this after doing some testing to see why people are having this problem. I provide below how to do this in MAMP Pro. This will also get rid of the :8888 at the end of the url as well.

  1. Download an install the latest version of MAMP
  2. Install MAMP
    • Install MAMP Pro – I recommend this if you work on multiple projects, it is way easier than editing your hosts file and the http.conf every time
    • If you are NOT using MAMP Pro please use this tutorial

Click to continue reading “Setting up MAMP Pro with Zend Debugger, Optimizer and Extension Manager”

Sep
28

Setting up MAMP with Zend Debugger, Optimizer and Extension Manager

Filed Under: MAMP, Zend

It seems some are having trouble setting up the Zend Debugger so i wrote this after doing some testing to see why people are having this problem. I provide below how to do this in MAMP. This will also get rid of the :8888 at the end of the url as well.

  1. Download an install the latest version of MAMP
  2. Install MAMP
    • Install MAMP Pro – I recommend this if you work on multiple projects, it is way easier than editing your hosts file and the http.conf every time
    • If you use MAMP Pro you will need to use this tutorial

Click to continue reading “Setting up MAMP with Zend Debugger, Optimizer and Extension Manager”

Sep
22

Windows XP SP3 breaking Microsoft Updates fix

Filed Under: Windows
Since Microsoft can’t get their head out of their ass i thought i would post this fix here. If you update to SP3 and you can no longer install updates from the windows update system you will need to register the wups2.dll file.

Click to continue reading “Windows XP SP3 breaking Microsoft Updates fix”

Aug
31

Use one SweetCron install for multiple domains

Filed Under: SweetCron

Well,

After playing with sweetcron for a bit I wanted to have 4 sites use it but I didn’t want to have to update each site everytime I need to update sweetcron. I found a little tweak you can do to get sweetcron working on multple domains with one install.

Click to continue reading “Use one SweetCron install for multiple domains”

Profile

Jeremy Simkins

Jeremy Simkins is an accomplished senior web developer with over nine years in the production field. Experienced PHP developer as well as a passionate software engineer. Jeremy specializes in code optimization, performance, and implementation.

View Jeremy Simkins's profile on LinkedIn

Open Source Projects

MPS Mod

FriendFeed

WordPress

Copyright ©2009 Jeremy Simkins. Theme Design by Noe Ruiz