404页面重定向到自定义页面

时间:2012-10-10 14:05:51

标签: apache .htaccess redirect http-status-code-404

例如,我有以下页面给出404错误

http://www.example.com/requirements/about-tn/about-us.html

如果上面的页面返回404错误

,我希望上面的页面显示以下网址

http://rd.example.com/requirements/about-tn/about-us.html

我怎么能在.htaccess中做到这一点?

理解

的问候, 拉加

1 个答案:

答案 0 :(得分:1)

www.example.com的文档根目录中的htaccess文件中,添加:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?requirements/about-tn/about-us.html http://rd.example.com/requirements/about-tn/about-us.html [L,R]
相关问题