| |

Bitesize .htaccess – Testing – Beginners Guide

Here we will test to see if your .htaccess file is turned on, and if it is working properly. This is easy for those new to .htaccess  Before you begin trying to make your first .htaccess file, let’s make sure you have things set up correctly. It is simple, here is all you need to do…

In your document root (folder), make a folder called /tests/.


In your Geany text editor make a file called google.php and put it in the folder called /tests/ that you just made.


In that file put only one line:

<?php phpinfo(); ?>

Now upload the file to your /tests/ folder.

Access the file from your browser. this will be something like one of these:

  • example.com/tests/google.php
  • localhost/tests/google.php
  • cafe.zoe/tests/google.php (what I did!)

 PHP Info

When I ran this file my browser displayed a full webpage of information about my server. At the top it said:

PHP Version 5.5.9-1ubuntu4.14


I used my “find” option to search the page for mod_rewrite

I found it under Configuration -> apache2handler ->Loaded Modules

Since I found it, it means I am ready to go!

.htaccess test

To test this, I will make a hidden file named .htaccess yes, the first character is a dot.  To see this hidden file on some file managers, and some FTP clients, you may have to find an option to show hidden files.

In this file I will put this:

# .htaccess cafe.zoe

RewriteEngine On
RewriteRule ^tests/google.php$ http://www.google.com/ [R=301]

Upload .htaccess to your document root.

Switch to your browser and try to view the same google.php page you did above, mine was:

  • cafe.zoe/tests/google.php

If all goes well, this time you will end up at www.google.com instead of seeing all your system information.

I Need PHPinfo Again

If you need to see the PHPinfo again, just comment out the rewriterule like this:

# RewriteRule ^tests/google.html$ http://www.google.com/ [R=301]

Upload again, then you can see the PHPinfo again.

Security Issue

Do Not leave the PHPinfo where the public can read it. It has too much information that can be used by Crackers to attack your website. You never want to give Crackers any extra information.


Your .htaccess is working for you!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *