本文介绍了需要一个正则表达式来匹配URL(无http,https,ftp)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在研究一个正则表达式,以匹配开头没有http
,https
或ftp
的URL.基本上,我需要它来进行mod_rewrite:
I am working on a regex to match URLs without http
, https
or ftp
in the beginning. Basically, I need it for mod_rewrite:
示例:
www.someurl.com/blah/blah/balh/etc/and/so/on
crazy.something.net/agjja
something.us/index.php?
所以,我可以做
RewriteCond %{REQUEST_URI} URLregexhere
RewriteRule ^URLregexhere$ ping.php?url=$1 [L]
推荐答案
根据定义,RewriteRule中正则表达式接收的所有内容都是一个URL(因为它已为请求提供了URL,而没有其他内容),因此完全匹配regex (.*)
就是您所需要的.
By definition everything that the regex in a RewriteRule is receiving is a URL (since it's fed the URLs for requests, and nothing else), so the match-all regex (.*)
is all you need.
这篇关于需要一个正则表达式来匹配URL(无http,https,ftp)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!