How To Test Check If Mod_rewrite Is Enabled
RegisterLogin
How To Test Check If Mod_rewrite Is Enabled
Post Description: How To Test Check If Mod_rewrite Is Enabled
Tags: How, To, Test, Check, If, Mod_rewrite, Is, Enabled
This Post Was Posted On Dec 15, 2009 By webmaster #463
Post Description: How To Test Check If Mod_rewrite Is Enabled
Tags: How, To, Test, Check, If, Mod_rewrite, Is, Enabled
This Post Was Posted On Dec 15, 2009 By webmaster #463
How To Test Check If Mod_rewrite Is Enabled by webmaster
DEMO: You can test how it work in our server, the link to the demo is at the bottom of this post
NOTE: If you prefer, you can download the complete script in the attachment provided on this post by our Webune Support Team. Or you can create the files yourself, if you choose to create the files yourself, continue reading...
We will be creating two files:
- rewrite.php
- .htaccess
IMPORTANT: its important that you do not change the name of the files we are creating on this post. if for example you choose not to call rewrite.php and choose to call this file something else like testing.php for example, it will not work. YOU MUST name the files as specified on this tutorial, otherwise, you will have problems. so follow instructions carefully
1. Open a blank notepad document
2. Copy and paste the following code into the blank notepad
<h2 align=center><?php /* mod_rewrite Test Page *//* Copyright 2006 Webune.com */if($_GET['link']==1){echo '<span style="color:red">You are not using mod_rewrite - Try LINK2</span>';} elseif($_GET['link']==2){echo'<span style="color:green">Congratulations!! You are using Apache mod_rewrite</span>';} else{echo '<span style="color:blue">Linux Apache mod_rewrte Test Tutorial</span>';} ?></h2><hr><title>How To Test mod_rewrite in Apache Linux Server</title><p align="center"><a href="http://www.webune.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html">Please Give Us Your Comments</a></p><p><a href="rewrite.php?link=1" style="color:red"><strong>LINK 1</strong></a> = LINK 1 Does NOT use Mod Rewrite. LINK 1 uses standard URL: <u>rewrite.php?link=1</u></p><p><a href="link2.html" style="color:green"><strong>LINK 2</strong></a> = LINK 2 - Yes, Uses Apache's Mod Rewrite using this URL:: <u>link2.html</u><br><br><br>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>NOTE: when you click on LINK2, you should see a message that says: Congratulations!! You are using Apache mod_rewrite</p><p>500 ERROR: If you get a 500 Error, this means you made a typo or mistake creating the files OR you are not allowed to use .htaccess</p><p>404 ERROR: if you get a 404 error, then this means you do not have Mod_Rewrite on this server.</p><p></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><br><br>NEED HELP? : <a href="http://www.webune.com/forums/how-to-fix-mod-rewrite-500-internal-server-error-on-htaccess-file-apache-t718.html" title="How To Fix Mod_rewrite 500 Internal Server Error On .htaccess File Apache">How To Fix Mod_rewrite 500 Internal Server Error On .htaccess File Apache</a></p><p align="center">Courtesy of<br><a href="http://www.webune.com"><img src="http://www.webune.com/images/headers/default_logo.jpg" alt="Webune Hosting" border="0"></a></p>
3. Now Save the file as "rewrite.php" - When you 'Save As..' in notepad, be sure to put quotes when you are saving the file, otherwise, notepad will add a .txt extension to the file, like this: rewrite.php.txt - is should only be rewrite.php, thats why you have to include the quotes
4. Now create a file called .htaccess - to make this type of file, open another blank notepad document
5. Copy and paste the following code into the .htaccess file:
# SCRIPT CREATED BY WEBUNE.COM
# THIS WORKS WITH rewrite.php FILE
# READ MORE AT: http://www.webune.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html
RewriteEngine On
RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]
# THIS WORKS WITH rewrite.php FILE
# READ MORE AT: http://www.webune.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html
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 .htaccess 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. Open the rewrite.php file with your browser to the location you just uploaded. for example:
http://www.your_website.com/test/rewrite.php
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 or you dont have permission to run .htaccess files on your website. talk to your web hosting company to make sure they allow apache .htaccess - Some hosting companies do not allow .htaccess because some people take advantage of this feature, so many web hosting companies block their users from using. so check with them
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.
Click here to See demo of mod rewrite file
if you still need more help, you can visit this link which also contains pictures/images to help you along if you are a beginner.
http://www.wallpaperama.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html
we have also put together the two files, you can download the full script or you can create the files yourself.
Download File: Test_ModRewrite.zip
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
hostlift dot com
#9812 1
very good post....it relly help us to understand the fact. Keep it up.
Jun 27, 2012 Reply Report abuse
Ameen
#9687 2
Thanks a lot, you work just solved my problem. I would like to buy you a drink for usd 5. How I could do it? Do you have a paypal account ?
Apr 30, 2012 Reply Report abuse
amitpatil.me
#9250 3
Ahhhaaa that worked for me :) thanks buddy
Dec 07, 2011 Reply Report abuse
fdsf
#9217 4
we have also put...
Nov 22, 2011 Reply Report abuse
bronski
#5515 5
great! thank you!
Oct 11, 2011 Reply Report abuse
Renato
#5427 6
very well done thi page.
thanks,
renato italy
thanks,
renato italy
Sep 04, 2011 Reply Report abuse
Chrisk
#5399 7
thanks sooo much dude!
Aug 22, 2011 Reply Report abuse
John
#5088 8
i created two files and tried to test(using xampp , windows xp sp2). my rewrite module is loaded and it is showing in phpinfo, then i checked apache/conf/httpd.conf file to set allowoverride value, it was set to all. but still this url rewriting is not working for me. please anyone can tell me the reason for this ?
May 06, 2011 Reply Report abuse
Upni
#4912 9
hi!
great job done!
thank you so much for explaining this. i did google but could not find much information. when i came to your post i found the great stuff to test my mod_rewrite. and it works for me. i have tested my server there was no mod_rewrite enabled. contacted my hosting and enabled my mod_rewrite. now it is working fine.
great job!!!!
great job done!
thank you so much for explaining this. i did google but could not find much information. when i came to your post i found the great stuff to test my mod_rewrite. and it works for me. i have tested my server there was no mod_rewrite enabled. contacted my hosting and enabled my mod_rewrite. now it is working fine.
great job!!!!
Mar 15, 2011 Reply Report abuse
JACK
#4719 10
thanks guys!
i'm sure now that 1&1 has not this mod_rewrite enabled in my webspace... i could not contact them cause missing proof, this site helped me getting something in the hand...
i'm sure now that 1&1 has not this mod_rewrite enabled in my webspace... i could not contact them cause missing proof, this site helped me getting something in the hand...
Dec 25, 2010 Reply Report abuse
Mr
#4684 11
well it seems someone don't know what they're talking about,,, mod_rewrite will not, does not, and never will work, even though it is installed and activated, personally, i avoid any scripts that try to use mod_rewrite, and even write my own scripts that use plain, good old <a href..... links
Dec 10, 2010 Reply Report abuse
Jithu
#4627 12
more or less even if you try calling mod_rewrite commands in the .htaccess file
eg: without the <ifmodule mod_rewrite.c>
directives like rewriterule ^(.*)$ index.php [qsa,l]
will result in internal server error..that way we can be pretty sure mod_rewrite is not enabled in the server
eg: without the <ifmodule mod_rewrite.c>
directives like rewriterule ^(.*)$ index.php [qsa,l]
will result in internal server error..that way we can be pretty sure mod_rewrite is not enabled in the server
Nov 17, 2010 Reply Report abuse
Machael
#4603 13
i got "
notice: undefined index: link in c:\apache2.2\htdocs\rewrite\index.php on line 1"
what did it mean?
notice: undefined index: link in c:\apache2.2\htdocs\rewrite\index.php on line 1"
what did it mean?
Nov 08, 2010 Reply Report abuse
Moves
#4574 14
thank you very much for posting this test!
Oct 27, 2010 Reply Report abuse
geek
#3959 15
mine says: you are not using mod_rewrite - try link2';} elseif($_get['link']==2){echo'congratulations!! you are using apache mod_rewrite';} else{echo 'linux apache mod_rewrte test tutorial';} ?>
May 08, 2010 Reply Report abuse
View More Comments
Leave Your Comments...
©2012 Webune Forums - Wed Jun 27, 2012 11:32 pm
Powered by: Webune Forums V3
Powered by: Webune Forums V3