/ Published in: Apache
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#**************************************** # Apache redirect from *.example.com to example.com #**************************************** RewriteEngine on #the domain does not match "example.com" #note that you need the end-of-string character $ or it wouldn't catch something like "example.com.example.com" RewriteCond %{HTTP_HOST} !^example\.com$ #replace the remainder of the URL: (.*) #with the full URL: http://example.com/$1 #make it a permanent redirect: R=301 #stop rewriting and do the redirection immediately: L RewriteRule (.*) http://example.com/$1 [R=301,L]
URL: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html