The .htaccess file

How to generate Htaccess Redirect File

Redirect old domain to new domain

Create a file called .htaccess in the doc root (web / httpdocs / www folder) of old-domain.com and put in the code below:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://new-domain.com/$1 [R=301,L]

The above is an example of the code for the domain transfer from old-domain.com to new-domain.com

Redirect to www

Create a file called .htaccess in the doc root (web / httpdocs / www folder) of mydomain.com and put in the code below

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^mydomain.com [nc]
rewriterule ^(.*)$ http://www.mydomain.com/$1 [r=301,nc]

The above is an example of the code for the domain transfer from http://mydomain.com to http://www.mydomain.com

Redirect old directory to new directory

Create a file called .htaccess in the doc root (web / httpdocs / www folder) of your domain and put in the code below

RedirectMatch 301 /old-directory/(.*) /new-directory/$1

The above is an example of the code for the domain transfer from http://mydomain.com/old-directory/ to http://www.mydomain.com/new-directory/

Redirect old URL to new URL

Create a file called .htaccess in the doc root (web / httpdocs / www folder) of mydomain.com and put in the code below

Options +FollowSymlinks
RewriteEngine on
rewriterule ^showresults.php(.*)$ http://otherdomain.com/displayresults.aspx$1 [r=301,nc]

The above is an example of the code for the redirect of old url http://mydomain.com/showresults.php to http://otherdomain.com/displayresults.aspx