How To Test Check If Mod_rewrite Is Enabled



How To Test Check If Mod_rewrite Is Enabled
 (387) PHP Mysql Hosting
How To Test Check If Mod_rewrite Is Enabled
Post Description:
Post Tags: how, to, test, check, if, mod, rewrite, is, enabled
This Post Has Been Viewed 14514 Times Since Thu Jul 20, 2006 2:34 pm Posted By webmaster with 7 replies
How To Test Check If Mod_rewrite Is Enabled
Webune customer benefit from apache's mod_rewrite. Every customer being hosted by our shared services has automatically mod_rewrite enabled. However, if you are still not sure whether you have this free service from Webune, you can confirm if its enable by following this simple guide. In this tutorial, you will be create two files, the first one called rewrite.php and the second one .htaccess - I will be using Windows XP notepad to create my files.

DEMO: You can test how it work in our server at the this link:
mod rewrite tutorial

1. Create a php file called "rewrite.php" with your text editor (notepad)
2. Copy and paste the following code into rewrite.php
<h2 align=center>
<?
// mod_rewrite Test Page
// Copyright 2006 Webune.com
if($_GET['link']==1){echo"You are not using mod_rewrite";}
elseif($_GET['link']==2){echo"Congratulations!! You are using Apache mod_rewrite";}
else{echo"Linux Apache mod_rewrte Test Tutorial";}
?>
</h2>

<hr>

<head>
<title>How To Test mod_rewrite in Apache Linux Server</title>
</head>

<body>
<p align="center">by <a href="http://www.webune.com">Webune</a></p>
<p><a href="rewrite.php?link=1">LINK1</a> = rewrite.php?link=1</p>
<p><a href="link2.html">LINK2</a> = link2.html</p>
<p>How this works: both links are for this same page, except they both are different. link one is without the mod_rewrite and link2 is using mod_rewrite. Link1 show the php file, with with mod_rewrite we are mascarading the php file into a html file. you can use whatever type of extension you want, you can change it to .htm or .shtml etc... all you have to do is to make sure you also chang it in the .htaccess file</p>
<p>&lt;&lt; <a href="http://www.webune.com/forums/viewtopic-p-62.html">Go back to webune forums.</a></p>
</body>
</html>


3. Save rewrite.php
4. Now create a file called .htaccess with your text editor like notepad
5. Copy and paster the following code into the .htaccess file:
RewriteEngine On
RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]

6. Save as .htaccess (if you are using notepad as I am, make sure to put quotes in between. example: ".htaccess" otherwise, notepad will create a file called .htacces.txt and we don't need the .txt at the end only .htaccess)
7. Now upload these two file into a new directory in your site. for example: test
8. Pull the rewrite.php file with your browser to the location you just upoaded.
9. you should see two links, LINK1 and LINK2 Click on LINK1 and the same page will display.
10. Now click on LINK2 and the same page will display with the a mod_rewrite message. If it doesnt you either did something wrong. Check your steps. If you checked your steps, refresh your browser, and if refreshing doesnt work, then you dont have mod_rewrite enabled.

If mod_rewrite is not working for you and you are a Webune customer, please contact our support team to assist you.

DEMO:
Click on this link. We have provided uploaded the files in this tutorial to show you how mod_rewrite works.

mod rewrite tutorial

Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About How To Test Check If Mod_rewrite Is Enabled




:: 1 :: #916 - Reply By lont On Sun Mar 18, 2007 3:08 pm
this is a good and helpful to show or display how to check if server has mod_rewrite. thanks
:: 2 :: #3154 - Reply By nioton On Mon May 14, 2007 7:14 am
sorry but this is not a useful code since you can not test it in a code and do some other action according to this ....
:: 3 :: #27217 - Reply By Sean On Sat Nov 10, 2007 11:36 am
most excellent! thanks for this; i needed a quick "down and dirty" test and you provided it brilliantly. =o)

sean p. o. maccath-moran
emanaton
:: 4 :: #27592 - Reply By DR On Tue Nov 13, 2007 12:34 pm
thanks very much - have been searching for something like this ..

not sure if everyone will get that:
8. pull the rewrite.php file with your browser to the location you just upoaded.
means - (put it in your browser's address bar )

thanks again

:: 5 :: #48386 - Reply By Ryan On Thu Apr 03, 2008 4:30 am
if ( in_array("mod_rewrite", apache_get_modules()) ) echo "mod rewrite on";

this is a far easier method....
:: 6 :: #54737 - Reply By Dragos On Thu May 22, 2008 8:27 am
very nice. it helped me!
seoanalytic
:: 7 :: #55139 - Reply By Raffaele On Sun May 25, 2008 10:17 am
thanks a lot for this small but very useful tool.

bye
raffaele
cip