Redirect Website IP and Non-WWW to Proper Address

# ------------------------------------------------- # # Redirect Website IP and Non-WWW to Proper Address # # ------------------------------------------------- # # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^123\.45\.67\.89$ RewriteCond %{HTTP_HOST} !^www.your-website.com$ RewriteRule ^(.*)$ http://www.your-website.com/$1 [L,R=301] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
Drop the following block inside your .htaccess file as a replacement for WP's default mod_rewrite rules.

The snippet will redirect your website IP address to your website's domain. Additionally, this snippet will redirect your short-url (ex: http://your-website.com) to your full address.

NOTE: Be sure to replace the `123.45.67.89` IP address and `your-website.com` domain with your website's actual IP and full WWW website address.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.