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

孤街醉人 提交于 2019-12-04 17:01:55

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

  • ajp:// - Apache JServ Protocol
  • balancer:// - Apache Load Balancer
  • fcgi://
  • ftp:// - File Transfer Protocol
  • gopher:// - Gopher (protocol)
  • http:// - Hypertext Transfer Protocol
  • https:// - Hypertext Transfer Protocol Secure
  • ldap:// - Lightweight Directory Access Protocol
  • mailto: - The mailto URI scheme
  • news: - News Protocol
  • nntp:// - Network News Transfer Protocol
  • scgi://
  • ws://
  • wws://

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

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

Perhaps I'm missing something but the prefix of the URL is the protocol. The client browsing to the url has an application bound to this protocol. HTTP(S) = Browser, MAGNET = torrent client, MAILTO = Email client, etc..

So if your client is configured to actually use that kind of url you will contact your server either in http or https.. so I'm guessing you can't check on protocol.. ?

If apache is accepting your request I guess you can check the entire url using %{SCRIPT_URI}.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!