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.


RewriteEngine on
#This rule will make all requests to have the www. in the URL
RewriteCond %{HTTP_HOST} ^ostoncodecypher\.com
RewriteRule ^(.*)$$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 ( with your domain or site name that u will be making the script for.So if you domain name was like this previously : it  will now look like this when the users visit it : with the WWW extension appended to it.

Related Post(s)

» How to prevent directory file listing on your website

» How to Create a Custom 404 Error Page in HTML.

» How to Force www Into URL.

collections_bookmark Category :: Servers
date_range Published :: 2 years ago At: 05:45 AM
event_note Detailed Date :: Dec 18th, 2018
person Writer :: Code