apache.htaccessmod-rewritecustom-url

How to handle mod-rewrite with a custom url scheme?


So here's my problem : I'm trying to do a redirection on a webpage with the htaccess file. This redirection will be towards a custom URL (i.e not something ike "http://..." but something like "myurl://...).

For now, I'm trying this on a little local apache server, in which I have a index.html page, a "test" directory and in this directory a .htaccess file and a test.html file.

Here's what's inside the .htaccess file :

Options +FollowSymLinks
RewriteEngine   On
RewriteBase /
RewriteRule     ^(.*)$ myurl://test$1 [R=302]

I think the problem probably comes from here, as I'm totally new at this and this is the first time I try to write into a .htaccess file. So, if this is not the proper way to do this, what is the proper way to do this then ?

Thanks to anyone who can help


Solution

  • The issue is related to the RewriteRule itself that checks the url scheme. From the source code mod_rewrite.c it reads only a subset of schemes:

    Protocols Recognized by Mod_Rewrite

    Indeed you can use RedirectMatch that doesn't check the protocol as follows:

    RedirectMatch /(.*) myurl://$1