How to Force www Into URL.

Alright, In this simple post i will show you how you can force the WWW ( World Wide Web) extension into your domain URL (Uniform Resource Locator).

To make this simple web development trick possible you need to create a file on your server called the  .htaccess . I will also show you how you can use this file to add security parameters to your website.

The apache method we are going to use will force the connection script to append the WWW extension to the domain URL incase its missing.

Place this piece of code in the .htaccess you created previously.

copy

RewriteEngine on
#This rule will make all requests to have the www. in the URL
RewriteCond %{HTTP_HOST} ^ostoncodecypher\.com
RewriteRule ^(.*)$ http://www.ostoncodecypher.com/$1 [R=permanent,L]

The statements that begin with the pound or hash symbol are considered to be comments.So they will have no effect on your script or code.

Note: Make sure you replace my domain name (ostoncodecypher.com) with your domain or site name that u will be making the script for.So if you domain name was like this previously : http://ostoncodecypher.com it  will now look like this when the users visit it : http://www.ostoncodecypher.com with the WWW extension appended to it.

collections_bookmark Category :: Servers
date_range Published :: 9 months ago At: 05:45 AM
person Writer :: Code

YOU MAY LIKE THESE POSTS