How to redirect one web page from one domain to another using .htaccess

How to get the following redirect to work?

olddomain.com/employee-scheduling-software.html

To redirect to

newdomain.us/employee-scheduling-software.html

I have mod_rewrite, but I'm basically a complete newbie in this area

+5
source share
2 answers
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^employee-scheduling-software.html$ http://newdomain.example.org/employee-scheduling-software.html
</IfModule>

You can change the rule to:

RewriteRule ^employee-scheduling-software.html$ http://newdomain.example.org/employee-scheduling-software.html [R=301]

which will send the title 301 Moved Permanentlyto the browser, so it will update its bookmarks and more.

+6
source

You can use this code in .htaccess on olddomain.com:

RewriteEngine on
RewriteRule ^employee-scheduling-software\.html$ http://newdomain.us/employee-scheduling-software.html [R,QSA]

Since it ^employee-scheduling-software\.html$is a PERL regular expression, you need to escape the dot in ".html" with a backslash ( \.).

employee-scheduling-software.html . , :

RewriteEngine on
RewriteRule ^(.*)$ http://newdomain.us/$1 [R,QSA]
0

All Articles