From: Eric Covener The If your URL path does not exist on the filesystem,
+ This directive is required for per-directory rewrites whose context
+ is a directory made available via the If your URL path does not exist verbatim on the filesystem,
+ or isn't directly under your Module: mod_rewrite RewriteBase
directive explicitly
- sets the base URL for per-directory rewrites.
+ sets the base URL-path (not filesystem directory path!) for per-directory rewrites.
When you use a RewriteRule
in a .htaccess
file, mod_rewrite
strips off
the local directory prefix before processing, then rewrites the rest of
the URL. When the rewrite is completed, mod_rewrite
automatically adds the local directory prefix back on to the path.Alias
+ directive.DocumentRoot
,
you must use RewriteBase
in every
- .htaccess
file where you want to use RewriteRule
directives. .htaccess
file where you want to use RewriteRule
directives.
The example below demonstrates how to map
- http://example.com/foo/index.html
to
+ http://example.com/myapp/index.html
to
/home/www/example/newsite.html
, in a .htaccess
file. This assumes that the content available at
http://example.com/
is on disk at
/home/www/example/
.
RewriteEngine On -RewriteBase /foo/ +# The URL-path used to get to this context, not the filesystem path +RewriteBase /myapp/ RewriteRule ^index\.html$ newsite.html
The .htaccess
file,
If your URL path does not exist on the filesystem, +
This directive is required for per-directory rewrites whose context
+ is a directory made available via the
If your URL path does not exist verbatim on the filesystem,
+ or isn't directly under your .htaccess
file where you want to use
The example below demonstrates how to map
- http://example.com/foo/index.html
to
+ http://example.com/myapp/index.html
to
/home/www/example/newsite.html
, in a .htaccess
file. This assumes that the content available at
http://example.com/
is on disk at
@@ -524,7 +529,8 @@ once!
RewriteEngine On
-RewriteBase /foo/
+# The URL-path used to get to this context, not the filesystem path
+RewriteBase /myapp/
RewriteRule ^index\.html$ newsite.html