how to test check if mod_rewrite is enabled

Mobile
feeds
Welcome Login | Register

how to test check if mod_rewrite is enabled
Reply Your Comments:
Click this button if you are interested in replying to this topic and leave your comments
Sent To Friend
CLick this button if you want to send this page to a friend.
Subsribe To Rss Feeds
Subscribe to RSS
CLick this button if you want to subscribe to this RSS Feed. You can use your browsers feeds burners if you have mozilla or internet explorer 7 or higher and keep up with updates.
  Forums Index
      » Tutorial and Guides Forums
        » » how to test check if mod_rewrite is enabled
how to test check if mod_rewrite is enabled
Post Description: how to test check if mod rewrite is enabled Tutorial and Guides
Post Tags:
This Post Has Been Viewed 27503 Times Since Thu Jul 20, 2006 2:34 pm Author webmaster with 15 replies
how to test check if mod_rewrite is enabled
Advertise On This Page




HI, welcome to wallpaperama.

Apache Mod_Rewrite module is a really handy and cool feature in Apache Web Server.

With mod_rewrite, you can show a different url than the actual url. you will also help your website make it more search engine friendly by avoiding having the ? (question mark) in your urls.

for example, this topic i am writing right now here at Wallpaperama, im actually using mod_rewrite, if you look at the url in your browser, its says:

http://www.wallpaperama.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html

but in reality, i am mascarading the actual php url. instead of using this url:

http://www.wallpaperama.com/forums/viewtopic.php?t=40

ok, the best way to learn is to actually do it yourself. if you have your website with a web hosting company that has mod_rewrite already enabled, then you shoulnnt have any problems. Webune.com customers benefit from apache's mod_rewrite. Every customer being hosted by our shared services has automatically mod_rewrite enabled.

You can confirm if its enable by following this simple tutorial guide. In this tutorial, you will be creating two files, the first one called rewrite.php and the second one .htaccess

- I will be using Windows XP notepad to create my files. ok, lets go..

step 1. to keep this organized, create a new directory (folder) called test
08p-40-mod-rewrite-1.gif

step 2. Open a blank notepad and copy and paste the following code into it:
08p-6606-mod-rewrite-php.gif

rewrite.php PHP CODE:
<h2 align=center>
<?php
// 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>


step 3. now save the file as rewrite.php in your test directory
08p-40-mod-rewrite-save.gif

step 4. Open a new blank notepad, we are going to create a file called .htaccess

step 5. Copy and paste the following code:

.htaccess File:
RewriteEngine On
RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]


step 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)
08p-40-mod-rewrite-httaccess.gif

step 7. You should have two files in your test directory: rewrite.php and .htaccess - Now upload the test directory with the two files rewrite.php and .htaccess into your website.
08p-40-mod-rewrite-ftp.gif

step 8. Open the rewrite.php file with your browser to the location you just uploaded the files. for example: http://www.yoursite.com/test/rewrite.php
08p-40-mod-rewrite-tutorial.gif

step 9. you should see two links, LINK1 and LINK2 Click on LINK1 and the same page will display.

step 10. Now click on LINK2 and the same page will display with the a mod_rewrite message. If it doesn't you either did something wrong. Check your steps. If you checked your steps, refresh your browser, and if refreshing doesn't work, then you don't have mod_rewrite enabled. if you dont have mod rewrite enabled in your server, then you might see something like this:
webune mod rewrite


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

if you need more help, i provided some other links to other posts on this subject. hope this helps.

thanks.



HELP

Here are some links to help you incase you are having trouble or its not working for you see related links


please provide any comments, i would like to learn from other by telling me why you need to learn mod rewrite so i can make more of these tutorials.


Leave Your Comments

Share:   Subscribe - Keep Up With This Topic
You can use this HTML code to put it on your website to show your friends this wallpaper. Use this code on your profile like myspace, friendster, Facebook or others. Just Copy and Paste it in your HTML on your websites
URL:
To embed this topic, just copy the code from the "Embed" box. Once you've copied the code, just paste it into your website or blog to embed it.
Embed:
BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums
Fourms BBCODE:
Links Related to : how to test check if mod_rewrite is enabled
Add Link:

Comments and replies About how to test check if mod_rewrite is enabled
:: 1 :: Reply #916 Reply By lont On Sun Mar 18, 2007 3:08 pm
lont:
this is a good and helpful to show or display how to check if server has mod_rewrite. thanks
:: 2 :: Reply #3154 Reply By nioton On Mon May 14, 2007 7:14 am
nioton:
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 :: Reply #27217 Reply By Sean On Sat Nov 10, 2007 11:36 am
Sean:
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 :: Reply #27592 Reply By DR On Tue Nov 13, 2007 12:34 pm
DR:
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 :: Reply #48386 Reply By Ryan On Thu Apr 03, 2008 4:30 am
Ryan:
if ( in_array("mod_rewrite", apache_get_modules()) ) echo "mod rewrite on";

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

bye
raffaele
cip
:: 8 :: Reply #63350 Reply By thilak On Fri Jul 25, 2008 11:08 pm
thilak:
hi...........hi...........hi.......
:: 9 :: Reply #87276 Reply By Simon On Tue Dec 23, 2008 2:30 am
Simon:
thanks for this - proved i'd properly implemented mod-rewrite on the apache server to my boss and it's his website that wasn't working :d
:: 10 :: Reply #92720 Reply By drale On Wed Feb 04, 2009 10:32 am
drale:
i had to add the test/ to the rule.

rewriterule ^test/link([^/]*).html$ test/rewrite.php?link=$1 [l]

or move rewrite.php into root for it to work.

i'm sure apache_get_modules() works as it is documented but for some reason it didn't work on my site. said it was undefined.
:: 11 :: Reply #99304 Reply By Shilpa On Sat Apr 04, 2009 9:44 am
Shilpa:
nice one. i have installed apache 1.3 on my local system. and have uncommented loadmodule and addmodule for mod_rewrite . also, allowoverride all.
restarted apache.
later placed the php file and .htaccess file as mentioned above in site. still the mod_rewrite is not working for me. could you please help. ?
:: 12 :: Reply #99307 Reply By Shilpa On Sat Apr 04, 2009 10:03 am
Shilpa:
nice one. i have installed apache 1.3 on my local system. and have uncommented loadmodule and addmodule for mod_rewrite . also, allowoverride all.
restarted apache.
later placed the php file and .htaccess file as mentioned above in site. still the mod_rewrite is not working for me. could you please help. ?
:: 13 :: Reply #99309 Reply By Shilpa On Sat Apr 04, 2009 10:03 am
Shilpa:
nice one. i have installed apache 1.3 on my local system. and have uncommented loadmodule and addmodule for mod_rewrite . also, allowoverride all.
restarted apache.
later placed the php file and .htaccess file as mentioned above in site. still the mod_rewrite is not working for me. could you please help. ?
:: 14 :: Reply #102858 Reply By east On Sat May 09, 2009 8:36 pm
east:
this wasn't working for me until i changed the second line of rewrite.php from <? to <?php. also, the author uses both .httaccess and .htaccess in the above. i mistakenly used the former (without thinking) and ran into problems (obviously, it should be .htaccess).
:: 15 :: Reply #102927 Reply By webmaster On Sun May 10, 2009 3:07 pm
webmaster:
thanks, i have corrected your issues.

:)