How To Test Mod Rewrite In Apacher Server
Post Description: How To Test Mod Rewrite In Apacher Server
Tags: How, To, Test, Mod, Rewrite, In, Apacher, Server
This Post Was Posted On May 26, 2010 By Webune #526
DEMO: You can test how it work in our server at the this link:
http://www.webune.com/tutorials/mod_rewrite/rewrite.php
If you prefer not to create the files yourself, we have created all the necessary files for you. see the attachment files in this post. if you create the files yourself and the script is not working, maybe you made a mistake, we recommend that you download the script better.
1. Create a php file called "rewrite.php" with your text editor (like notepad)
2. Copy and paste the following code into "rewrite.php"
PHP CODE:
<?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/how-to-test-check-if-mod-rewrite-is-enabled-t40.html">Go back to webune forums.</a></p>
</body>
</html>
3. Save As ... "rewrite.php"
4. Now create a file called .htaccess with your text editor like notepad
5. Copy and paste the following code into the .htaccess file:
HTACCESS CODE:
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 you get a 500 Error, then you do not have mod_rewrite enabled in your server. Or 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. http://www.webune.com/tutorials/mod_rewrite/rewrite.php
We have provided uploaded the files in this tutorial to show you how mod_rewrite works.
Download all the files in the attachement below if you dont want to create the files yourself
the server encountered an internal error or misconfiguration and was unable to complete your request.
please contact the server administrator, admin - at - localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
more information about this error may be available in the server error log.
i still have this problem after i wrote those 2 codes .....i'am going crazyyyy
zend framework problems with mod_rewrite the requested url /prueba was not found on this server.
please help
# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Includ /etc/apache2/mods-enabled/*.conf
# cat /etc/apache2/mods-enabled/rewrite.load
rewrite_module /usr/lib/apache2/modules/mod_rewrite.so i dont have idea really what to do...

Not Found
The requested URL /link2.html was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8b mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.5 Server at example.com Port 80
Powered by: Webune Forums V3