Bowen | The Definitive Guide to Apache mod_rewrite | E-Book | sack.de
E-Book

E-Book, Englisch, 160 Seiten, eBook

Bowen The Definitive Guide to Apache mod_rewrite


1. Auflage 2006
ISBN: 978-1-4302-0122-9
Verlag: APRESS
Format: PDF
Kopierschutz: 1 - PDF Watermark

E-Book, Englisch, 160 Seiten, eBook

ISBN: 978-1-4302-0122-9
Verlag: APRESS
Format: PDF
Kopierschutz: 1 - PDF Watermark



Organizing websites is highly dynamic and often chaotic. Thus, it is crucial that host web servers manipulate URLs in order to cope with temporarily or permanently relocated resources, prevent attacks by automated worms, and control resource access. The Apache mod_rewrite module has long inspired fits of joy because it offers an unparalleled toolset for manipulating URLs. The Definitive Guide to Apache mod_rewrite guides you through configuration and use of the module for a variety of purposes, including basic and conditional rewrites, access control, virtual host maintenance, and proxies. This book was authored by Rich Bowen , noted Apache expert and Apache Software Foundation member, and draws on his years of experience administering, and regular speaking and writing about, the Apache server.
Bowen The Definitive Guide to Apache mod_rewrite jetzt bestellen!

Zielgruppe


Professional/practitioner


Autoren/Hrsg.


Weitere Infos & Material


An Introduction to mod_rewrite.- Regular Expressions.- Installing and Configuring mod_rewrite.- The RewriteRule Directive.- The RewriteCond Directive.- The RewriteMap Directive.- Basic Rewrites.- Conditional Rewrites.- Access Control.- Virtual Hosts.- Proxying.- Debugging.


When Not to Use mod_rewrite (p. 4)

As important as knowing when and how to use mod_rewrite is having a firm grasp on what other tools Apache offers, so that you know when not to use mod_rewrite. All of mod_rewrite’s amazing power comes at the cost of performance. Running regular expressions consumes time and memory, and it’s ideal to avoid it if alternate approaches are available.

However, even when there are one or more alternate approaches, it is seldom the case that one option is clearly the best one to use all the time. There are always a number of factors that you need to consider.

Just as there are several categories in which mod_rewrite use tends to fall, there are also several categories into which common misuse of mod_rewrite falls, as we’ll cover in the following sections.

Simple Redirection
Probably the most common misuse of mod_rewrite is for simple redirection. Redirection is used when a client requests one URL, and we want to give them a different one instead. In many cases, this is a simple one-to-one mapping. That is, it could be a mapping of one URL to another URL, or perhaps one directory to another directory, and sometimes even a mapping of one virtual host to another one, or perhaps to another server entirely.

In each of these cases, the Redirect directive is sufficient. The syntax of the Redirect directive is as follows:

Redirect [Original] [Target]

where [Original] is the URL that was originally requested, and [Target] is the fully qualified URL to which you wish to redirect it. When the user requests the original URL, Apache will send a redirection message back to the browser, which will then request the new URL.

The address appearing in the address bar of the user’s browser will change to the new URL. This approach requires a second round-trip to the web server in order to retrieve the content. The advantage of this approach, in addition to simplicity, is that the new corrected URL is announced to the user (who may or may not notice), but also that an automated process such as a search engine indexer will update its records to reflect the new URL and stop requesting the old one.

Several examples of the Redirect directive follow:

Redirect /index.cfm http://www.example.com/index.php

In this example, only one possible URL is redirected. That is, if someone requests

http://www.example.com/index.cfm, they will be sent instead to

http://www.example.com/

index.php, but no other URLs will be affected.

In this next example, we’ve renamed our /pics/ directory to /images/ instead, and we want all requests for things in /pics/ to go to /images/ instead:

Redirect /pics/ http://www.example.com/images/


Rich Bowen is a world-recognized expert and member of the Apache Software Foundation. He has authored several books on Apache, and regularly contributes to the Apache Server documentation project.



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.