开发者

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

开发者 https://www.devze.com 2023-01-16 00:07 出处:网络
How do I get the following redirect to work? olddomain.com/employee-scheduling-software.html To redirect to

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


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


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]
0

精彩评论

暂无评论...
验证码 换一张
取 消