Regex

Posted on: October 1, 2010 Posted by: JJ Comments: 0

Regex

Detect subdomain and rewrite the front part of the subdomain:

.htaccess

[sourcecode]
RewriteCond %{HTTP_HOST} ^auto(.*)domain.com
>RewriteRule ^(.*)$ http://quotes%1domain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^auto(.*)domain.comRewriteRule ^(.*)$ http://quotes%1domain.com/$1 [R=301,L]
[/sourcecode]

Search and replace the domain only:

[sourcecode]
/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#?=~_|!:,.;]*[-A-Z0-9+&@#%=~_|]\/)/i
[/sourcecode]