Recipe 5.3 Creating a New URL for Existing Content

Problem

You have an existing directory which you want to access using a different name.

Solution

Use an Alias directive in httpd.conf:

Alias /newurl /www/htdocs/oldurl

Discussion

While Alias is usually used to map URLs to a directory outside of the DocumentRoot directory tree, this is not necessarily required. There are many times when it is desirable to have the same content accessible via a number of different names. This is typically the case when a directory has its name changed, and you wish to have the old URLs continue to work, or when different people refer to the same content is by different names.

Remember that Alias only affects the mapping of a local URI (the /foo/bar.txt part of http://example.com/foo/bar.txt); it doesn't affect or change the hostname part of the URL (the http://example.com/ part). To alter that portion of the URL, use the Redirect or RewriteRule directives.

See Also

  • Recipe 5.2

  • http://httpd.apache.org/docs/mod/mod_alias.html

  • http://httpd.apache.org/docs/mod/mod_rewrite.html



Apache Cookbook
Apache Cookbook: Solutions and Examples for Apache Administrators
ISBN: 0596529945
EAN: 2147483647
Year: 2006
Pages: 215

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net