不用 .htaccess apache nginx rewrite 5分鐘完成301/302轉址

www.aaa.com 因為公司策略調整,要把現在的服務改成www.bbb.com
傳統做法是使用 .htaccess 或是在 apache / nginx 做 301 / 302 轉址
.htaccess的寫法如下
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.aaa.com.tw$[OR]
RewriteCond %{HTTP_HOST} ^aaa.com.tw$
RewriteRule ^(.*)$ http://www.bbb.com/$1 [R=301,L]

Read more

Virtual Host to Enablye the Header Rewrite.

If we got the message show as as below, we may not enablye the apache rewrite function.
2009-02-28_071618.png
To enable this function we should modify the httpd.conf.
Add these command line in the virual host block

RewriteEngine On
Options +FollowSymlinks

To save the httpd.conf and Restart the apache.
when you wirte the .htaccess file without errors, and
your will get the rewrite function.
if not, you man find out the issue from the log.