How do I handle mod-rewrite with a custom url scheme?

So here is my problem: I am trying to do a redirect on a webpage with an htaccess file. This redirect will be directed to the custom URL (ie not something like "http: // ..." but something like "myurl: // ...").

I'm currently trying to do this on a small local Apache server where I have an index.html page, a "test" directory, and in that directory there is an .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 is probably coming from here, as I am completely new to this and this is the first time I am trying to write a .htaccess file. So if this is not the correct way to do it, what is the correct way to do it?

Thanks to everyone who can help

+1


source to share


2 answers


The problem is with the one itself RewriteRule

, which checks the URL scheme. From the mod_rewrite.c source code, it only reads a subset of the schemas:

Protocols recognized by Mod_Rewrite

  • ajp: // - Apache JServ Protocol
  • balancer: // - Load balancing Apache
  • FCGI: //
  • ftp: // - File transfer protocol
  • gopher: // - Gopher (protocol)
  • http: // - Hypertext Transfer Protocol
  • https: // - Secure Hypertext Transfer Protocol
  • ldap: // - Lightweight directory access protocol
  • mailto: - The mailto URI scheme.
  • news: - News protocol
  • nntp: // - Network news transfer protocol
  • SCGI: //
  • WS: //
  • OSV: //


Indeed, you can use RedirectMatch

that does not check the protocol like this:

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

      

+7


source


I may be missing something, but the url prefix is ​​the protocol. The client viewing the url has an application associated with this protocol. HTTP (S) = Browser, MAGNET = torrent client, MAILTO = mail client, etc.

So, if your client is configured to use this url, you access your server in either http or https .. so I assume you cannot check the protocol.?



If apache accepts your request, I think you can check the whole url using% {SCRIPT_URI}.

-1


source







All Articles