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.
Copyright ©2009 Jeremy Simkins. Theme Design by Noe Ruiz