How To Test Check If Mod_rewrite Is Enabled
Posted On Thu Jul 20, 2006 By webmaster In Tutorial And Guides Forums And Topics Discussions For Help Forums
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 masquerading the actual php url. instead of using this url:
http://www.wallpaperama.com/forums/viewtopic.php?t=40
if you prefer to download the full script, you can do so by downloading the attachment at the bottom of this post
otherwise, you can continue and create the files yourself:
IMPORTANT!!! - if you are going to follow this tutorial by each step, be sure to name the files as i describe, if you name them something else, the script will fail. so if you dont want to go through the stpes, you can download the whole script i provided:
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

step 2. Open a blank notepad and copy and paste the following code into it:

rewrite.php PHP CODE:
step 3. now save the file as rewrite.php in your test directory

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:
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)

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.

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

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:
404 ERROR - If you are getting a 404 Error (Page Not Found) this means you dont have mod_rewrite on your website
500 ERROR = a 500 error means that the code you put on your .htaccess has a problem. Apache cannot process the syntax. the most common mistake people make is they type something wrong like mispelled something. so double check to make sure you have exactly the code i provided above. and be sure you have named the files as i told you.
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.
if creating the files yourself is too complicated, you can download the full script at the bottom of this post.
see a demo: mod rewrite tutorial
if you need more help, i provided some other links to other posts on this subject. hope this helps.
thanks.
here is a short video a made to show you how you can enable on linux:
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.
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 masquerading the actual php url. instead of using this url:
http://www.wallpaperama.com/forums/viewtopic.php?t=40
if you prefer to download the full script, you can do so by downloading the attachment at the bottom of this post
otherwise, you can continue and create the files yourself:
IMPORTANT!!! - if you are going to follow this tutorial by each step, be sure to name the files as i describe, if you name them something else, the script will fail. so if you dont want to go through the stpes, you can download the whole script i provided:
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

step 2. Open a blank notepad and copy and paste the following code into it:

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><< <a href="http://www.webune.com/forums/viewtopic-p-62.html">Go back to webune forums.</a></p>
</body>
</html>
<?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><< <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

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]
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)

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.

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

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:
TROUBLESHOOT:
404 ERROR - If you are getting a 404 Error (Page Not Found) this means you dont have mod_rewrite on your website
500 ERROR = a 500 error means that the code you put on your .htaccess has a problem. Apache cannot process the syntax. the most common mistake people make is they type something wrong like mispelled something. so double check to make sure you have exactly the code i provided above. and be sure you have named the files as i told you.

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.
if creating the files yourself is too complicated, you can download the full script at the bottom of this post.
see a demo: 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 linkshere is a short video a made to show you how you can enable on linux:
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.
4845|2|28|999|12-p1396-test-modrewrite.zip
tartanphoenix Sun Mar 04, 2012
This wasn't working for me until I added this as a second line
RewriteBa /test/
RewriteBa /test/
hauke Wed Jan 11, 2012
thx, for the script
raven Mon Oct 24, 2011
really handy little script - good work guys
gumuruh Sat Oct 15, 2011
ya, me also...
while testing it inside windows xp,
enabling the
LoadModule rewrite_module modules/mod_rewrite.so inside httpd.conf, and trying to create htaccess.txt inside my local directory gives me 404 result.
How to solve it out?
while testing it inside windows xp,
enabling the
LoadModule rewrite_module modules/mod_rewrite.so inside httpd.conf, and trying to create htaccess.txt inside my local directory gives me 404 result.
How to solve it out?
tset Thu Jul 14, 2011
php server, phpinfo visit page, search for mod rewrite.
Spiros Tue May 31, 2011
or you can use
<?PHP
print_r(apache_get
<?PHP
print_r(apache_get
Hector Mon May 30, 2011
Thank you for the tutorial! it really help me. I did have the mod_rewrite enabled, but this little piece of information opened my mind for other things. Thanks Again!
sabastian Mon Nov 29, 2010
hello, im kinda new to this mod rewrite business. i dont fully understand it, but i guess your tutorial showed me exactly what i needed to do. i have XAMP and it works. i can't believe it worked on the first try. now if i can just figure out how you did it.
anyways, just wanted to say thank you guys for putting this kinda stuff. keep up the good work.
anyways, just wanted to say thank you guys for putting this kinda stuff. keep up the good work.
kevin Mon Jul 26, 2010
Hi
and thanx very very much. finally i solve da great problem. thax. thax. and thax.
you example is very useful and deep.
keep your great work
and thanx very very much. finally i solve da great problem. thax. thax. and thax.
you example is very useful and deep.
keep your great work
MR.GREEN Sat Jun 05, 2010
The test works but I still can't get mysite dot com /?pr to display as mysite dot com /Busines I'm very confused how it works both ways especially if there's a strict condition or just about any condition for that matter. Please fill the gaps in my thinking thanks.
nitish Wed Apr 14, 2010
thanks a lot, that was helpful, i have been looking for how to use mod_rewrite.
thanks again
thanks again
dkz Fri Feb 26, 2010
Big thanks guys, you rescue me. ^O^
Simple but great result.
Simple but great result.
james Fri Feb 19, 2010
Brilliant - looked around the web for ages trying to figure out how to suss this and this really helped!
Cheers
Cheers
wallpaperama Wed Jan 13, 2010
on SUN ONE, yes you can but its really hard. unless you are a unix guru otherwise i would recommend you start with LINUX
mike Wed Jan 13, 2010
does anyone know if SUN ONE supports mod rewrite or if i can install apache on a sun server?
thanks <3
thanks <3
Related Content
Information
Forums »
Tutorial And Guides Forums And Topics Discussions For Help »
How To Test Check If Mod_rewrite Is Enabled
Tutorial And Guides Forums And Topics Discussions For Help »
How To Test Check If Mod_rewrite Is Enabled
Title: How To Test Check If Mod_rewrite Is Enabled
Description: this is very good and easy to follow step by step tutorial on how you can test or check to see if mod rewrite is enabled on your server for your website just follow my steps and i will show you ow to test check if mod rewrite is enabled Tutorial and Guide
Tags: mod rewrite , apache , module , test , enable , configuration , settings , check
Info: This Post Has Been Viewed 0 Times Since
Date: Thu Jul 20, 2006
Author webmaster Received 34 Replies #1396
Date: Thu Jul 20, 2006
Author webmaster Received 34 Replies #1396
Share
URL: 

Embed: 

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
BBCODE:: 

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
wallpaperama | Wallpapers | Forums | Terms Of Service
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5