From: Rich Bowen
Date: Tue, 13 Jan 2015 20:43:17 +0000 (+0000)
Subject: Insert htaccess/RewriteRule examples, illustrating how RewriteRule
X-Git-Tag: 2.4.11~22
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfa4e67b2e08c723cdb2c640c4303a47b0d6e6e2;p=thirdparty%2Fapache%2Fhttpd.git
Insert htaccess/RewriteRule examples, illustrating how RewriteRule
syntax is weird in .htaccess files.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1651482 13f79535-47bb-0310-9956-ffa450edef68
---
diff --git a/docs/manual/howto/htaccess.html.en b/docs/manual/howto/htaccess.html.en
index 6bcf0cf59bd..b8917dbc9e3 100644
--- a/docs/manual/howto/htaccess.html.en
+++ b/docs/manual/howto/htaccess.html.en
@@ -37,6 +37,7 @@ changes on a per-directory basis.
How directives are applied
Authentication example
Server Side Includes example
+
Rewrite Rules in .htaccess files
CGI example
Troubleshooting
@@ -329,6 +330,34 @@ AddHandler server-parsed shtml
Please see the SSI tutorial for a more
complete discussion of server-side includes.
+
+
+
+
When using RewriteRule
in
+.htaccess
files, be aware that the per-directory context
+changes things a bit. In particular, rules are taken to be relative to
+the current directory, rather than being the original requested URI.
+Consider the following examples:
+
+
# In httpd.conf
+RewriteRule ^/images/(.+)\.jpg /images/$1.png
+
+# In .htaccess in root dir
+RewriteRule ^images/(.+)\.jpg images/$1.png
+
+# In .htaccess in images/
+RewriteRule ^(.+)\.jpg $1.png
+
+
+
In a .htaccess
in your document directory, the leading
+slash is removed from the value supplied to RewriteRule
, and in the
+images
subdirectory, /images/
is removed from
+it. Thus, your regular expression needs to omit that portion as
+well.
+
+
Consult the mod_rewrite documentation for
+further details on using mod_rewrite
.
+

diff --git a/docs/manual/howto/htaccess.xml b/docs/manual/howto/htaccess.xml
index ada3e73ec59..8853cf08ebc 100644
--- a/docs/manual/howto/htaccess.xml
+++ b/docs/manual/howto/htaccess.xml
@@ -363,6 +363,36 @@ AddHandler server-parsed shtml
complete discussion of server-side includes.
+
Rewrite Rules in .htaccess files
+When using RewriteRule in
+.htaccess
files, be aware that the per-directory context
+changes things a bit. In particular, rules are taken to be relative to
+the current directory, rather than being the original requested URI.
+Consider the following examples:
+
+
+# In httpd.conf
+RewriteRule ^/images/(.+)\.jpg /images/$1.png
+
+# In .htaccess in root dir
+RewriteRule ^images/(.+)\.jpg images/$1.png
+
+# In .htaccess in images/
+RewriteRule ^(.+)\.jpg $1.png
+
+
+In a .htaccess
in your document directory, the leading
+slash is removed from the value supplied to RewriteRule, and in the
+images
subdirectory, /images/
is removed from
+it. Thus, your regular expression needs to omit that portion as
+well.
+
+Consult the mod_rewrite documentation for
+further details on using mod_rewrite
.
+
+
+
CGI example
Finally, you may wish to use a .htaccess
file to permit