S
S
Sergey Mushtuk2013-11-20 15:59:11
Domain Name System
Sergey Mushtuk, 2013-11-20 15:59:11

How to make a 301 redirect for all IPs except your own?

There is a site that, for SEO, wants to make a 301 redirect from a domain with www to a domain without www.
At the same time, from the internal office network using split-DNS and raised on a Windows server, the site on the domain without www is not visible, a stub is shown (for the internal DNS group, mail is full there, etc.).

Since the problem with split-DNS and the office network is difficult to solve, I thought it would be easier to make a 301 redirect from www to without www for all visitors except from the office IP. Is it really easier? How is it written at the htaccess / mode_rewrite level?

Maybe what other solutions to this problem are possible?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Kazarinov, 2013-11-20
@serkaz

RewriteEngine On
RewriteCond %{REMOTE_ADDR} !1.2.3.4
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

D
Dmitry, 2013-11-20
@kasus

what's the problem with making a subdomain like mail.example.com for mail, etc.?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question