Apache Server for Windows Little Black Book:Image Maps And Redirection
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Apache Server for Windows Little Black Book
(Publisher: The Coriolis Group)
Author(s): Greg Holden with Matthew Keller
ISBN: 1576103919
Publication Date: 01/01/99
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
Enabling URL Rewriting
The most complex way to redirect a request is to make use of the many URL rewriting rules provided by the mod_rewrite module or URL Rewriting Engine. This is a very sophisticated and well-documented aspect of Apaches functionality, and an in-depth examination of mod_rewrite is beyond the scope of this book. However, you can find out more about this modules directives by referring to the document C:\Apache\htdocs\manual\mod\mod_rewrite.html in Apaches documentation; you can also refer to the Web page created by the modules author, Ralf S. Engelschall (www.engelschall.com/pw/apache/rewriteguide/).
The mod_rewrite module is not compiled into Apache by default. You have to make the module available to Apache by following these steps:
1. Open httpd.conf in Notepad.
2. Uncomment the following line:
#LoadModule rewrite_module modules/ApacheModuleRewrite.dll
3. Next, enable mod_rewrite by setting one of its nine directives, RewriteEngine, to on (by default, RewriteEngine is set to off). Enter the following in httpd.conf or srm.conf or within an .htaccess file:
RewriteEngine on
TIP: If you set RewriteEngine to on within an .htaccess file, you must also enable Apache to follow simulated links within the appropriate context. If the directory is part of a virtual host, make sure Options FollowSymLinks is enabled within the <VirtualHost> container. However, mod_rewrite processes per-directory (that is, .htaccess) rewriting by employing a trick that causes the servers processing load to rise. You should avoid URL rewriting within a directory unless its absolutely necessary.
4. Choose File|Save to save your changes.
5. Restart Apache for the changes to take effect.
What makes the URL Rewriting Engine so different from other redirection approaches is that it lets you use regular expressions to map requested URLs to another file or to a different URL. You set up rules and conditions for requested URLs, and if the URLs are caught by the regular expressions you set up, mod_rewrite can rewrite them to other URLs or to file names (it can rewrite file names to other file names, too).
The mod_rewrite module can rewrite URLs on a per-server basis, but it can also manipulate URLs within an .htaccess file. Per-directory rewrites will progress more slowly, however.
Specifying Rewrite Rules
After mod_rewrite is set up, you can set up a rewrite rule. To do so, use the RewriteRule directive, which has two required arguments. Here is its syntax:
RewriteRule pattern to be matched string to be substituted
The pattern to be matched can be a regular expression that is applied to the requested URL. The substitution string can be plain text, a back-reference to a pattern to be matched, a server variable, or a mapping-function call.
In addition to RewriteRule, you can add an extra condition by preceding RewriteRule with one or more RewriteCond directives. RewriteCond follows this syntax:
RewriteCond test string condition-pattern
The test string argument is a string that can consist of plain text or back-references from the current rewrite rule and the last rewrite condition.
Here are some very simple examples of how these directives can be used to rewrite a requested URL:
To temporarily redirect all incoming requests to your server, to another server, or to another file, enter the following:
RewriteEngine on
RewriteRule ^/(.+) http://somewhereelse.com/
This will take all requests from a server and move them off-site.
If you want to do the same sort of redirection, but move visitors to another location within your own site, you could enter the following:
RewriteEngine on
RewriteRule ^/(.+) C:/somedir/elsewhere/$1
This will move all requests to a directory on the local file system. The $1 tells Apache to keep the URL intact, so a request for http://myserver.com/bob/chris (which on the file system could be located at C:\Apache\htdocs\bob\chris) would now be directed to C:\somedir\elsewhere\bob\chris.
Previous
Table of Contents
Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.
Wyszukiwarka
Podobne podstrony:
223 227 6fcwctb2pglckpptczkjmjgfc6sdcxsk6lmqcji222 223218 219WCE2012 pp218 223223 228Mazowieckie Studia Humanistyczne r1997 t3 n1 s211 223223 232więcej podobnych podstron