开发者

Need a regex to match URL (without http, https, ftp)

I am working on a regex to match URLs without http, https or ftp in the beginning. Basically, I need it for mod_rewrite:

Examples:

www.someurl.com/blah/blah/balh/etc/and/so/on
crazy.something.net/agjja
something.us/index.php?
开发者_StackOverflow社区

So, I can do

RewriteCond %{REQUEST_URI} URLregexhere
RewriteRule ^URLregexhere$ ping.php?url=$1 [L]


You want to match everything?

RewriteCond %{REQUEST_URI} !^/?ping\.php
RewriteRule (.*) ping.php?url=$1


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜