Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to implement a server-relative redirect using existing Apache features?

mod_alias does have a Redirect command, but that one always generates an absolute redirect even if configured like

Redirect /asdf /qwer

Also tried using mod_rewrite like this:

RewriteEngine On
RewriteRule /asdf(.*) /qwer$1 [R,L]

The end result of either of these settings is the same:

HTTP/1.0 302 Found
Location: http://my-host.blah.blah:20085/qwer

But what I really need is:

HTTP/1.0 302 Found
Location: /qwer

--- EDIT ---

Yes, I know this is against RFC spec. But all modern browsers support a relative redirect, and I really need it for a temporary fix.

share|improve this question

1 Answer 1

That is the way Redirect works; from the manual:

The new URL should be an absolute URL beginning with a scheme and hostname, but a URL-path beginning with a slash may also be used, in which case the scheme and hostname of the current server will be added.

From RFC 2616, section 14.30:

The field value consists of a single absolute URI.

share|improve this answer
1  
It may be an incorrect redirect, but all modern browsers support it. See en.wikipedia.org/wiki/HTTP_location –  RustyX Jul 24 '12 at 9:55
    
I never said it was incorrect, and his question was whether apache supports it. In short, no :) –  adaptr Jul 24 '12 at 9:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.