Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

2014-02-19

Level Up - Webmaster: How To Randomly Redirect Visitors To Different Websites

There is a very simple method using PHP to have visitors automatically redirected to another site.

Why this is useful:
- User clicks "Take me to a random" page. You can finely-tune the random outcome.
- You are doing some A/B testing and want to sent users to different locations to test.
- Or, like me, you want to share your various websites/games, from a single button.

Try clicking
Ex: http://apps.simplyadvanced.net/windows8/redirect

Step 1: Here's all the PHP code that you need:

$urls = array("siteA.com",
              "siteB.com",
              "www.example.com"); $url = $urls[array_rand($urls)]; header("Location: http://$url"); ?>

Step 2: Done

Or, if you want to redirect the visitor after they visit a certain URL on your domain, then simply create an "index.php" file in the public directory that you want users to be redirected from, then the above code is all that you need to put in it.

Try it: Random Windows 8 Games created by me.
Try it: Random Windows Phone Games created by me.

~ Danial Goodwin ~



2014-02-08

Level Up - Webmaster: Installing Laravel and Composer on Bluehost

These steps will get you though getting Laravel up and running on your Bluehost server, though these instructions should be a good enough how-to for other shared hosting providers as well.

This was my first time experiencing (and hearing of) Laravel and Composer and had to look at many websites to figure this information out. Below is a walkthrough of all the steps I would have needed in one location. For more advanced and specific informations, I provide links at the end. But, the steps shown should be enough to get going quickly from scratch.

1.  SSH into your server at ~/bin/
2. Ensure that you have PHP 5.3.7+ on your server. Composer requires 5.3.2+ and Laravel requires PHP 5.3.7+. You can check with which php and which php-cli
3. Install Composer: Run the command curl -s http://getcomposer.org/installer | php
4. Test that the installation worked by running php-cli composer.phar
5. Install Laravel: Run the command php-cli composer.phar create-project laravel/laravel --prefer-dist
Note: Step 5 may take a minute or two, there are many dependencies that have to also be installed for Laravel.

Extra steps
6. Look at this file for project-specific adjustable values: app/config/app.php and bootstrap/paths.php
7. See my next post for more walkthrough

More info:
- Laravel installation instructions
- Laravel configuration instructions
- Then, the Quickstart


Error: "warning: composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI"
Fix: Use the command php-cli instead of php.


~ Danial Goodwin ~