PHP Redirect 301 Permanently

Sometimes you might want to redirect your visitors to a new URL address. This article will show you how to make a PHP redirect using the 301 “moved permanently” redirection. This is the one you should use as it is the most search engine friendly. Like the name suggests, PHP redirect tells the browser (or a search engine bot) that the page has been permanently moved to a new location.

PHP Redirect Code

To redirect people and robots to a new location use this PHP redirecting code:

header("HTTP/1.1 301 Moved Permanently");

You could skip the 301 Moved Permanently tag and use just:


But this would result in a “302 Moved Temporarily” redirect instead of a 301 one. This should be avoided as permanent redirects are more search engine friendly and should be used where possible.

You can enter any sub-page for the location, this PHP code will redirect users to the test.php sub-page of your website:

header("HTTP/1.1 301 Moved Permanently");

It is important that you don’t have any other code (including empty rows and spaces) before the above PHP redirect code. If you do you will get a nice headers already sent notice from PHP and the redirect will not work.

That’s it! Enjoy redirecting PHP pages.

No Comments

How to reset Zimbra Admin Password

To reset the administrative password:

su - zimbra
zmprov sp <admin email address> <new password>

To get a list of all administrators:

su - zimbra
zmprov gaaa

Remember that the administrative console (sometimes) requires a full email address as the login name, so you may be using the correct password and the wrong login!

No Comments

45 Life tricks from a 90 year old

  1. Life isn’t fair, but it’s still good.
  2. When in doubt, just take the next small step.
  3. Life is too short not to enjoy it.
  4. Your job won’t take care of you when you are sick. Your friends and family will.
  5. Don’t buy stuff you don’t need.
  6. You don’t have to win every argument. Stay true to yourself.
  7. Cry with someone. It’s more healing than crying alone.
  8. It’s OK to get angry with God. He can take it.
  9. Save for things that matter.
  10. When it comes to chocolate, resistance is futile.
  11. Make peace with your past so it won’t screw up the present.
  12. It’s OK to let your children see you cry.
  13. Don’t compare your life to others. You have no idea what their journey is all about.
  14. If a relationship has to be a secret, you shouldn’t be in it.
  15. Everything can change in the blink of an eye… But don’t worry; God never blinks.
  16. Take a deep breath. It calms the mind.
  17. Get rid of anything that isn’t useful.  Clutter weighs you down in many ways.
  18. Whatever doesn’t kill you really does make you stronger.
  19. It’s never too late to be happy.  But it’s all up to you and no one else.
  20. When it comes to going after what you love in life, don’t take no for an answer.
  21. Burn the candles, use the nice sheets, wear the fancy lingerie. Don’t save it for a special occasion. Today is special.
  22. Over-prepare, then go with the flow.
  23. Be eccentric now. Don’t wait for old age to wear purple.
  24. The most important sex organ is the brain.
  25. No one is in charge of your happiness but you.
  26. Frame every so-called disaster with these words, ‘In five years, will this matter?’
  27. Always choose Life.
  28. Forgive but don’t forget.
  29. What other people think of you is none of your business.
  30. Time heals almost everything. Give Time time.
  31. However good or bad a situation is, it will change.
  32. Don’t take yourself so seriously. No one else does.
  33. Believe in miracles.
  34. God loves you because of who God is, not because of anything you did or didn’t do.
  35. Don’t audit life. Show up and make the most of it now.
  36. Growing old beats the alternative — dying young.
  37. Your children get only one childhood.
  38. All that truly matters in the end is that you loved.
  39. Get outside every day. Miracles are waiting everywhere.
  40.  If we all threw our problems in a pile and saw everyone else’s, we’d
    grab ours back.
  41. Envy is a waste of time. Accept what you already have, not what you think you need.
  42. The best is yet to come…
  43. No matter how you feel, get up, dress up and show up.
  44. Yield.
  45. Life isn’t tied with a bow, but it’s still a gift.

No Comments

Linux command list for System Info

  1. pwd

    Prints the current working directory (Print Working Directory)

  2. hostname

    Print the name of the local host (the machine on which you are working). If you want to change the name of the machine, Use netconf (as root).

  3. id username

    Print user id (uid) and his/her group id (gid), effective id (if different than the real id) and the supplementary groups.

  4. whoami
    Prints your login name.
  5. date
    Print or change the operating system date and time. If you want to change the date and time to 2010-12-31 23:57 using this command:
    date 123123572010
    To set the hardware (BIOS) clock from the system (Linux) clock, use the command (as root) setclock
  6. who
    Determine the users logged on the machine.
  7. rwho -a
    (remote who) Determine all users logged on your network. The rwho service must be enabled for this command to run. If it isn’t, install “rwho”.
  8. time
    Determine the amount of time that it takes for a process to complete + other info. Don’t confuse it with thedate command. E.g. I can find out how long it takes to display a directory content using:
    time ls
  9. finger username
    System info about a user. Try: finger root
  10. last
    Show listing of users last logged-in on your system.
  11. history | more
    Show the last (1000 or so) commands executed from the command line on the current account. The “| more” causes the display to stop after each screenful.
  12. uptime
    Show the amount of time since the last reboot.
  13. ps
    (Process Status) List the processes currently run by the current user.
  14. ps axu | more
    List all the processes currently running, even those without the controlling terminal, together with the name of the user that owns each process.
  15. top
    Keep listing the currently running processes, sorted by cpu usage (top users first). In KDE, you can get GUI-based Ktop from “K”menu under “System”-”Task Manager” (or by executing “ktop” in an X-terminal).
  16. uname -a
    (Unix Name with option “all”) Info on your (local) server. I can also use guname (in X-window terminal) to display the info more nicely.
  17. free
    Memory info (in kilobytes).
  18. df -h
    (Disk Free) Print disk info about all the filesystems (in human-readable form)
  19. du / -bh | more
    (Disk Usage) Print detailed disk usage for each subdirectory starting at the “/” (root) directory (in human legible form).
  20. cat /proc/cpuinfo
    Cpu info–it show the content of the file cpuinfo. Note that the files in the /proc directory are not real files–they are hooks to look at information available to the kernel.
  21. cat /proc/interrupts
    List the interrupts in use.
  22. cat /proc/version
    Linux version and other info
  23. cat /proc/filesystems
    Show the types of filesystems currently in use.
  24. cat /etc/printcap
    Show the setup of printers.
  25. lsmod
    (As root. Use /sbin/lsmod to execute this command when you are a non-root user.) Show the kernel modules currently loaded.
  26. set|more
    Show the current user environment.
  27. echo $PATH
    Show the content of the environment variable “PATH”. This command can be used to show other environment variables as well. Use “set” to see the full environment.
  28. dmesg | less
    Print kernel messages (the content of the so-called kernel ring buffer). Press “q” to quit “less”. Use less /var/log/dmesg to see what “dmesg” dumped into this file right after the last system bootup.

No Comments

How to install git on Red Hat Linux / Cent OS

Git is dependent on the follow libraries, make sure they are installed.

yum install zlib-devel
yum install openssl-devel
yum install perl
yum install cpio
yum install expat-devel
yum install gettext-devel

Curl will need to be installed from source. The current version from Red Hat/Cent OS doesn’t work correctly with Git.

tar xzvf curl-7.18.0.tar.gz
cd curl-7.18.0
make install

Next, make sure /usr/local/lib is in your, this is required for git-http-push to correctly link up to the Curl version you are installing.

vi /etc/

(Insert the following)

Save the file, then run:

Now download and install Git

tar xzvf git-latest.tar.gz
cd git-date
./configure --with-curl=/usr/local
make install

No Comments

What’s the difference between 301 redirects and 302 redirects [Quick Answer]

Quick answer: 301 – permanent redirect and 302 – temporary redirect.

No Comments

FOSFacebookBundle: “The Facebook user could not be retrieved from the session.” (a possible solution)

If you get the message below when you try to connect to your site via Facebook Connect,

The Facebook user could not be retrieved from the session.

You just need to change your localhost URL on your own hosts file that Facebook can give you cookie permission of which is blocked by default for localhost development.
To do that, just add a new line below to your hosts file; localhost.local
And do not forget to change your application settings at to allow your new application URL http://localhost.local/your_app/.

Thank you for reading.

No Comments

Overall Summary of my First Week on the New Job at Enuygun.Com

The end of the week showed up for me and I feel like writing about my firs week at Enuygun.Com. Firstly, I haven’t learn much about the company but I think its a kind of new but successful company. I’m a senior software developer here and we’re going to build applications, services, mobile applications and an affiliate system for all we can share the growth. We are using Symfony2 as PHP framework of which I had no idea at the beginning. For the first 2 days it was like what a horrible structure that everything is bundled and you need to create new bundle to use the other bundle. At least, that’s what I think it was. After a huge concentration on research and watching some tutorials about Symfony, I now can say that, it might be the best framework to be used to develop easily implemented bundles that could be used by many applications. It’s not that none of the other frameworks don’t have the ability but it is for me now that when I think about bundled or plug in based system development is Symfony.

All in all, although I did not have any clue about the technology that they have been using till now, I think I made a grate performance to figure out what is what, why it is used and how I can use things while I have my developer hat put-on. So, the thing is, is totally new for me and I feel like I’m going to be successful as I used to be on the previous companies. But I should note that, getting a job far away from your home is not the best choice. But it was a quick shoot. I hope I made a good decision.

Thank you for reading.

No Comments

Compressing Stylesheets with PHP

If you wonder what else you can do to compress your files, I found a PHP code of which is written by a German coder that is shared on another blog. Basicaly it removes spaces and back slashes to minify the included files and compress them using ob_gzhandler.

  header('Content-type: text/css');
  function compress($buffer) {
    /* remove comments */
    $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
    /* remove tabs, spaces, newlines, etc. */
    $buffer = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $buffer);
    return $buffer;

  /* your css files */


No Comments

Compressing Web Site Contents, Scripts and Stylesheets

Today I wonder how I could minify my javascript files and do a server side compression to minimize the cost of loading web site requred javasript and stylesheet files. Where to begin… I’ll start from Apache Server configuration information for server side compression and finish with YUI Compressor that helps you to minify your script files as you should have seen those files ending with “your_script_file.min.js”. If you are using Apache Server, you might have Deflate Module installed with your Apache installation. What you need to load this module while your your server starts is to configure your apache configuration file.

LoadModule deflate_module modules/

And if you have access to the httpd.conf then you can add following lines to it.

<Location />
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/x-js text/css

If not; you should specify the initialization line into your htaccess file.

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/css text/plain text/javascript text/xml application/xhtml+xml application/x-httpd-php

You might have problems to compress javascript files which has different mime types. Then, you can use followig configuration.

AddOutputFilterByType DEFLATE application/x-javascript

That will do. Now, I will introduce YUI Compressor. YUI Compressor is one of Yahoo developer team product that you can download from here. If you have dowloaded the YUI Compressor built from the site that I shared above, what you should do to compress your file is:

java -jar yuicompressor-x.y.z.jar myfile.js -o myfile-min.js --charset utf-8

Where, x, y and z are the version number of the YUI Compressor download. Also you can find more information about YUI Compressor at

Thank you for reading, I hope this will help some of you guys.

No Comments