开发者

how to convert sub-domain URL to domain URL using smarty

I have a URL like this

http://subdomain.domain.com/xyz-开发者_JAVA技巧200_some_information

I want to convert this URL to following URL using smarty.

http://www.domain.com/xyz-200_some_information

That is, need to replace subdomain with www

subdomain is not fixed, there may be more more subdomains. I'm looking for a smarty based solution instead of a PHP one, as I don't have to acc change


You can use a regex_replace

{$var|regex_replace:"/http:\/\/.*?\./":"http://www."}

This matches a region from http:// to the first dot and replaces it with http://www.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜