Force the Website URL to Include “www” and to be Upper Case?

No matter what url somebody uses to access my site, I’d like it to redirect to www.MyUrl.com. Is this possible?

Solutions Collecting From Web of "Force the Website URL to Include “www” and to be Upper Case?"

As far as i know there is no way to force the url to uppercase.

As for forcing the www. this can vary as to where you are hosting etc.

Here is one generic way of doing this using your .htaccess file.

# Forcing www. infront of domain
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^(domain\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

Hi @FigBug:

1.) You can easily force “www” in your domain because WordPress handles it all for you. You’ll only need to set two defines in the /wp-config.php file is found in your website’s root; this is the same file where your database userid and password is stored.

Add these two lines to your /wp-config.php file somewhere before the require_once(ABSPATH . 'wp-settings.php'); line:

define('WP_HOME',"http://www.myurl.com");
define('WP_SITEURL',WP_HOME);

2.) You cannot force domain capitalization. Domains are case-insensitive. Even if you try WordPress will lowercase it.

(So give it up, it ain’t happening! 🙂

There are lots of ways to force a redirect from a given URL to a preferred variant of that URL. Which one you use will depend upon how much control you have over your environment. Some include:

  • Use the WordPress control panel settings.
  • Use the Apache .htaccess URL rewriting capabilities.
  • Use the Apache Redirect permanent directive from the Apache configuration. (All webserver should have a similar mechanism.)

What you have to keep in mind is that domain names are NOT case-sensitive, and in this case the browser will control what gets displayed, not your server. More importantly, each redirection you force will (1) require additional work from your server, (2) increase the complexity of your configuration, and (3) delay your users from accessing your site. If your goal is to enhance your brand (MyUrl instead of myurl) you’d be better served by focusing on the design of your site.

There are two real reasons to implement site redirection to force a given domain:

  1. Reduce search engine confusion (everyone uses myurl.com instead of http://www.myurl.com or web.myurl.com or 12.34.56.78).
  2. Ensure that all users of a SSL-protected site use the same domain that is registered in the SSL certificate, mostly to prevent error messages and confusion.