Return to Snippet

Revision: 16048
at March 9, 2010 09:03 by wizard04


Updated Code
#****************************************
# 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]

Revision: 16047
at March 9, 2010 09:01 by wizard04


Updated Code
#****************************************
# Apache redirect from *.example.com to example.com
# 
# #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]
#****************************************

RewriteEngine on
RewriteCond %{HTTP_HOST} !^example\.com$
RewriteRule (.*) http://example.com/$1 [R=301,L]

Revision: 16046
at July 24, 2009 10:23 by wizard04


Initial Code
RewriteEngine on
RewriteCond %{HTTP_HOST} !^dragonzreef\.com$
RewriteRule (.*) http://dragonzreef.com/$1 [R=301,L]

Initial URL
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

Initial Description


Initial Title
Apache Redirect from *.example.com to example.com

Initial Tags
regex, redirect, htaccess, apache

Initial Language
Apache