Mod_rewrite redirects url with proprietary protocol

I am using Apache 2.2 with mod_rewrite.

Is there a way to force mod_rewrite to rewrite the entire URL including the protocol? I know that it will automatically rewrite the entire url if the redirect contains http://

at the beginning, but I am trying to redirect to a url that uses the proprietary protocol:fcp://

When I add it as a redirect, it just redirects to my server url with a rewrite added like this:

http://www.example.com/fcp://@mailstaff....

      

Can I configure the module to handle it fcp://

as a full URL so that I don't work with that?

UPDATE: Here is the code I'm using:

RewriteCond ${externals:$2|Unknown} !Unknown
RewriteRule ^(internal|external)/(.*)/? ${externals:$2} [R=301,NE,L,NS]

      

Inside the externals

RewriteMap, I have a line like this:

firstclass-email        fcp://@mailstaff.example.com/

      

When I go to run the RewriteRule by going to:

http://example.com/internal/firstclass-email

      

It will incorrectly redirect me here:

http://example.com/fcp://@mailstaff.example.com/

      

If I change the part of the protocol fcp://

to http://

, Apache will understand his absolute URL and running properly. I want Apache to recognize fcp://

must also be absolute.

+2


source to share


4 answers


Apache can handle most common scheme URL, such as http

, https

, ftp

, mailto

etc. Custom URL schemes are not recognized as such, but are treated as a URL path.



For details on which schemas are supported, see the functions is_absolute_uri

in the mod_rewrite.c source code .

+2


source


You can use RedirectMatch

instead RewriteRule

.



Check out How to handle mod-rewrite with a custom url scheme? for an explanation ...

+2


source


Have you tried this?

RewriteRule ^/yourUrl$ fcp://otherUrl [RL]

      

0


source


Quite an old question - but I can answer. I have the same problem. This can be solved with two redirects.

Redirect /restore1 fcp://example.com/restore

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (android|bb\d+|meego).+mobile.....
RewriteCond %{HTTP_USER_AGENT} ^(1207|6310|6590|3gso|.....
RewriteRule ^restore/(.*)$ http://example.com/restore1/$1

      

0


source







All Articles