views:

21

answers:

2

How do I get the following redirect to work?

olddomain.com/employee-scheduling-software.html

To redirect to

newdomain.us/employee-scheduling-software.html

I do have mod_rewrite on, but I'm basically a complete novice in this area

A: 
<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 into:

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

which will send a 301 Moved Permanently header to the browser, so it updates its bookmarks and stuff.

aularon
It turns out this got the job done, thanks for your help.RewriteCond %{http_host} ^olddomain\.com$RewriteRule ^employee-scheduling-software\.html$ http://newdomain.us/employee-scheduling-software.html [R=301,L]
A: 

You could 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 the ^employee-scheduling-software\.html$ is a PERL regex, you need to escape the dot in ".html" with a backslash (\.).

This will just redirect employee-scheduling-software.html to the new domain. If you want to redirect all files to the new domain, use:

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