Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 650
user445293 Avatar asked Sep 11 '10 21:09

user445293


People also ask

How do I redirect a URL to another domain?

You changed your domain name and you want to redirect all requests to the new domain? You can create such a redirect by adding a few lines in the site's . htaccess file. To redirect with a 301 HTTP response ( Moved Permanently ), use R=[301,L] on the last line.

Should I enable 301 .htaccess redirect?

The . Because the WordPress 301 redirect is not always reliable, we recommend issuing the 301 redirect via your . htaccess file. Another benefit is that the . htaccess redirect is slightly faster than redirecting via PHP, because it is loaded even before the rest of the page.


1 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 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.

like image 105
aularon Avatar answered Sep 19 '22 12:09

aularon