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
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.
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
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.
Click to continue reading “Setting up MAMP Pro with Zend Debugger, Optimizer and Extension Manager”
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.
Click to continue reading “Setting up MAMP with Zend Debugger, Optimizer and Extension Manager”
Click to continue reading “Windows XP SP3 breaking Microsoft Updates fix”
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”
Copyright ©2009 Jeremy Simkins. Theme Design by Noe Ruiz