There are times when you need to change your domain name. It is not uncommon that people change there domain name for various reasons.
There are many reasons for changing the domain name, like finding a better name, short name or an exact keyword name.
While changing a name seems easy, but the process required is time consuming and technical.
To smoothly change or redirect the name their can be issues in the script and the name not resolving at all.
If you encounter problems, there are some simple solutions which can help in smooth transition to new domain name with the help of a .htaccess file and mod_rewrite.
The rule based rewriting engine, mod_rewrite is based on PCRE regular expression, which can re-write URLs immediately.
The default function of mod_rewrite is to map an URL to file-system path. Nonetheless, it can also redirect a URL to a different URL.
With the help of mod_rewrite and .htaccess application files, changing/redirecting domain names becomes seamless and smooth.
Well now, what is a mod_rewrite?
Mod_Rewrite is an Apache module that permits the function of rewriting a URL. This allows URLs to be customized as needed.
When used properly for changing domain names, end user is not aware of the change, and is absolutely transparent.
When using mod_rewrite to redirect the old URL to new URL, the old URL is visible for a split second before the user see’s the new domain name. This method of domain change is very search engine friendly.
What is .htaccess file?
A .htaccess file runs on Apache Web Server and is a configuration file, this file can be used to enable or disable some functions of the web server.
One of the function this file can perform is redirect a URL. For instance if you have moved your content to another location on your web server, you can redirect visitors from old content links to new content links.
Some of the other functions of .htaccess files are used in preventing other websites from hot linking your images and sourcing your content.
These are some of the functions that mod_rewrite and .htaccess file can perform.
Before making any changes to these files or in some cases making new files, It is important to note that some issues might come up.
For a smooth change from one domain to other, it is important to check with your web host that they support the mod_rewrite module, or else you will not be able to make the required change.
If your host supports mod_rewrite, the next step is to create an .htaccess file. To create this file you just need a text editor, notepad can do the job.
Create a text file and save it as .htaccess, and now you can open this file in any text editor and insert your syntax.
Now this file is ready to be uploaded to your web server and perform the required functions.