Simple HTACCESS question to redirect IP to domain name
I'm looking to redirect an IP address to a domain name using HTACCESS. So anytime the IPaddress.com/subdir1/page1.html shows up it'll redirect to domainname.com/subdir1/page1.html
I've tried this with NO LUCK:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [OR]
RewriteCond %{HTTP_HOST} ^123\.45\.67\.89
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Becau开发者_StackOverflow社区se it ONLY redirects the main IP address to the main domain, not subdirectory ips to subdirectory domains
Thank you Jeff
Pretty old now, but maybe you meant RewriteCond %{REMOTE_ADDR}
Looks like you probably just forgot a ^
and maybe a $
or two... No reason this shouldn't work:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^123\.45\.67\.89$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
精彩评论