Sunday 3 August 2014

Redirect Url To Another Url in Apache Server

To redirect a url to another url ,you have to make a htaccess File.

example: if we want to redirect url www.abc.com to http://www.example.com/
See the below steps to redirect url :

1.On an Apache server. The htaccess file on an Apache web server handles error requests, redirection and other requests.
2.Understand 300 http codes. The code "301" is most commonly used on redirected sites, and means "moved permanently".
3.Type or paste the following code into the text file:
RewriteEngine On
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
“L” indicates that it’s the last instruction and “R” means redirect, and “301” means a permanent redirect.
4.Learn how to redirect a url with spaces in the name, dynamic pages, sub-domains and other special features by searching online.[1]
5.Change “example.com” to the actual domain name.
6.Click “save.”Save the file as .htaccess with no extension.


.htaccess

RewriteEngine On
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

No comments:

Post a Comment

Printing first 50 Fibonacci numbers Using PHP Program

Fibonacci series is a series of numbers in which each number is the sum of the two preceding numbers. For example. 0 , 1 , 1 , 2 , 3 , 5...