mod_rewrite enabling url reqriting on apache and iss server windows and linux
URL reqriting is Simple Rewriting Your URLS (links) Also Redirecting Them To Known URLS.
e.g
you’ll make the link : view_my_profile.html –> Is Redirected to function.php?op=3
so
instead of the link “function.php?op=3″ Which isn’t enough describing itself we’ll make the link “view_my_profile.html” Which is very describtive.
Why using mod_reqrite?. Now see if your site has more than 10,000 Links (Dynamic Website) , do you think we would make 10,000 html files ??
=>Of course Not , and here’s the Use Of Mod-Rewrite. We can achive dynamic pages from code and rewrite their URL using this module.
=>well simply This is Very very useful for search Engines to correctly index Your website and gather keywords, we’ll talk about this in details in “Search Engine Optimization Tips”
How to Enable Mod_rewrite:-
how to configure mod_reqrite to work It Depends On Your Operating System (Server’s Software) .
- For Linux It’s Supported By Default (in Most Of The Servers) - ModRewrite Is An Apache Module You Don’t Have To Setup Anything And We wont Go On How To Install The Mod-Rewrite On Your Linux Server Cause It’s little Advanced And Complicated.However you can have mod_rewrite module loaded in apache.
- For windows : A lot of developers think that it’s not supported by windows server but infact it is.I’ll Describe How You Can Set it Up On windows (Assuming That You Have IIS installed On Your PC/Server).But If You Haven’t Then You Can Refer To This Post: showthread.php?t=1 (http://www.phpegypt.net/forum/showthread.php?t=1)
- For Windows XP / 2003 Server
- You Must Download The Files From ( http://www.iismods.com/download.htm ) also I Attached It to This Post .. [It's Free Released under the GNU General Public License (v2)](May be this link is not working sometimes.)
- Place It Somewhere on your H.D.D let’s Say “c:\mod_rewrite”
- Goto Control Panel -> Administrative Tools -> Internet Information Services
- You’ll Find Your Computer name And bet ween 2 Brackets (localhost) Click it -> open “Web Sites” -> “Default Website”.
- Right click on “Default Website” Choose “properties”.
- You’ll Find Many Tabs At The Top Click “ISAPI Filters”.
- Click Add, Enter “MOD_REWRITE” As The filert name And For The executable Click “Browse” And Choose The file “c:\mod_rewrite\mod_rewrite.dll” or just choose The file “mod_rewrite.dll” Which You Extracted In The Desired Folder.
- Now Click “Ok” ,Mod Rewrite Should Appear In The List now With Empty Status , and Filername = “MOD_REWRITE” and priority *unknown*..
- Now You’re Ready To Run The MOD_REWRITE, Click Start->Run
- Enter the following “iisreset” and click O.K It’ll Perform 4 Quick Operations (restart the iis server) And The window Will Close After That You’re Ready To Test Your ModRewriteNow Assuming That Everything Goes Right.
- For Windows XP / 2003 Server
- Apache/Wamp PHP based:-
- For apache windows WAMP server you can turn the mod_rewrite extension on by
- Right clicking on wamp icon click on mod_rewrite.
- Restart wamp server.
- For apache windows WAMP server you can turn the mod_rewrite extension on by
- Apache Linux/Windows Without WAMP:-
-
RewriteRule Source Destintion [options]
Description:
RewriteRule: Syntax Keyword That Must Exist Before Any Rule
Source: The Source Link That Will Appear In Browser & For Users
Destintion: The Translated (Replaced) Link That Will Appear To The Server.
[options]: Some Extra Options That Can Be Left Empty
e.g. [L] To make This Rule The Last And Server Shouldn’t Continue Fetching Rules After it . . . And many Other Options That Will Come Later
Now Let’s Make Our First Example:
RewriteRule ^helloworld.html index.php?module=hello
-
Now You Can Play Around With URLs Like :
RewriteRule ^contactus.html index.php?oper=contactus
RewriteRule ^aboutus.html index.php?mod=about
RewriteRule ^login.html index.php?op=login
……
etc.
* Just Remember
Your .htaccess (apache) should be looking like this :
RewriteEngine On
RewriteRule ^login.html index.php?do=login
Or your mod_rewrite.ini (IIS with mod_rewrite FILTER):
Debug 0 # This Line Isn’t Important
Reload 500 # This Line Isn’t Important
RewriteRule ^login.html index.php?do=login
-
=>In Windows Your Rules Will be Written In The file “c:\mod_rewrite\mod_rewrite.ini” And In Linux (Apache) Rules Will be written in “.htaccess” (A File That Will/May be located on the root of your website).
So Configuring PHP on iss server is simple..!




Leave a Reply
You must be logged in to post a comment.