Re: What is the difference between redirect and rewrite?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2009-01-22 at 08:39 +0800, Chongwei Chen wrote:
> For Apache server, sometimes I see people use very simple redirect rule such
> as:
> 
> redirect 301 / http://www.yourdomain.com/
> 
> But sometimes use a very complex rewrite rule to implement a redirect such
> as:
> 
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^domain\.com
> RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
> 
> What is the difference between the two, does the second one more advanced
> and better than the first one?

IIUC, the RewriteCond in the second approach would make the redirect
apply only to virtual hosts ending in domain.com, but if you take it
out, the two are essentially equivalent.  I wouldn't say one approach is
better than the other for a simple redirect, but the second gives you
more flexibility if you needed to fine-tune the behavior.

-- 
Matt


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux