Forum Moderators: phranque

Message Too Old, No Replies

Relative URL for new URL in Redirect directive

         

anjanesh

7:39 am on Jan 15, 2009 (gmt 0)

10+ Year Member



Why do Redirect, RedirectMatch, RedirectPermanent all require absolute URLs for the new URLs ?

Is there no way to specify a relative one ?

Caterham

10:32 am on Jan 15, 2009 (gmt 0)

10+ Year Member



For the pattern, the directives operate on r->uri and not r->filename, for the substitution: You would clone code complexibility from mod_rewrite which is not intended of course.
To issue a redirect, apache must build an URL. mod_rewrite can build an URL-path from a local path automatically, if your site lives under the document_root and r->filename with striped document_root is the corresponding URL-path. If you don't have a document_root variable (e.g. mass virtual hosting by mod_vhost_alias) or the URL-path is not directly related to the filesystem path, you'll have to specify the URL-path via the RewriteBase directive.

Cloning such features into mod_alias is not intended.

jdMorgan

5:06 pm on Jan 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You may find that the answer lies in the difference between an external redirect and an internal rewrite [webmasterworld.com].

The Redirect and RedirectMatch directives in mod_alias do external redirects as their names imply, whereas mod_rewrite does external redirects OR internal rewrites (or proxy through-puts), depending on the syntax that you specify in your RewriteRule directive.

Jim

g1smd

8:26 pm on Jan 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If URLs could be relative, then you would not be fixing www vs. non-www Duplicate Content issues within the redirect.

You'd need a second redirect to fix those, and that Redirection Chain would cause issues all of its own.