如果域包含特定IP,则htaccess重定向

So our temporary server looks a little something like this:

78.171.44.99/domain.co.uk

That'll be what our client goes to when they want to get access the development site. However, despite constant reminders that the website is now live and running, they keep trying to access the site via the temporary url.

To idiot-proof this issue, is there a little htaccess redirect I could use to redirect them?

from 78.171.44.99/domain.co.uk to www.domain.co.uk

Thanks.

You can use this rule as first rule in your site root .htaccess:

RewriteCond %{HTTP_HOST} ^\d+\.\d+\.
RewriteRule ^(domain\.co\.uk)(.*)$ http://www.$1$2 [L,R=301,NC,NE]

In the document root of your dev site, add this near the top of the htaccess file:

RedirectMatch 301 ^/domain.co.uk(.*) http://www.domain.co.uk$1

or if you're using mod_rewrite already, add:

RewriteEngine On
RewriteRule ^domain.co.uk(.*) http://www.domain.co.uk$1 [L,R=301]