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

E-Book, Englisch, 160 Seiten, eBook

ISBN: 978-1-4302-0122-9
Verlag: APRESS
Format: PDF
Kopierschutz: Adobe DRM (»Systemvoraussetzungen)



* The Definitive Guide to Apache mod_rewrite is the first book devoted to mastering mod_rewrite, Apache’s most powerful (and confusing) module.
* It is authored by noted Apache expert and Apache Software Foundation member Rich Bowen, who draws on several years of extensive experience administering the Apache server as well as speaking and writing regularly on the topic.

* This book covers all matters pertinent to mod_rewrite: installation and configuration, basic and conditional rewrites, access control, maintaining virtual hosts, and proxying.
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.