Home HOW TO Test your Website Support mod_rewrite or Not

kenlapz.ORG - House of Joomla Designer

HOW TO Test your Website Support mod_rewrite or Not

E-mail Print PDF
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.kenlapz.org/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.kenlapz.org/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

Step 1. Create the test file (rewrite.php)

Open a blank notepad and copy and paste the following code into it and save it to rewrite.php.


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



Step 2. Save and Upload rewrite.php.

 
Now save the file as rewrite.php and upload it to your Webhosting public_html directory

Step 3. Create, Save and Upload .htaccess file

Open a new blank notepad, we are going to create a file called .htaccess and copy following code:

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

After you save the file, upload it to your Webhosting public_html directory (same with the rewrite.php file).  And now you should have two files in your test directory: rewrite.php and .htaccess on your webhosting.
 
08p-40-mod-rewrite-ftp.gif


Step 4. Make a test

 
Open the rewrite.php file with your browser to the location you just uploaded the files. for example: http://www.yoursite.com/rewrite.php

08p-40-mod-rewrite-tutorial.gif

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

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 and you should contact your webhosting administrator to solve it.

webune mod rewrite

 

Members Panel

  • user LOGIN


- Do not have an account? Register
- Lost your Password? Resend Password
- Lost your Confirmation Link? Resend Confirmation Link

Partner Website

Latest Joomla Tips and Tricks

Upload & Download Information

Popular Joomla Tips and Tricks

Sponsor Links

Members Statistic

Latest Member : livestar888
Members Online : 0
Today : 0 Registers
This Week : 0 Registers
This Month : 10 Registers

Partner Websites


Website Statistics

Members : 19137
Content : 1354
Web Links : 9
Content View Hits : 1425721