httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nigel Peck <np.li...@sharphosting.uk>
Subject Re: [users@httpd] redirect vs. rewrite
Date Mon, 26 Jun 2017 20:08:09 GMT

Sorry, one other point, using `[R]` in number two will generate a 302 
redirect whereas the first, using the permanent keyword, will generate a 
301.

On 26/06/2017 15:07, Nigel Peck wrote:
> 
> Also note that the first one will always redirect to the root of the 
> target domain, but the second one will redirect to the same page on the 
> target domain.
> 
> First one:
> (taking Daniel's comment in to account)
> 
> /example redirects to http://www.domain.com/
> 
> Second one:
> 
> /example redirects to http://www.domain.com/example
> 
> First one is using mod_alias[1], second one is using mod_rewrite[2]. Mod 
> rewrite has more flexibility and can handle complex situations, for 
> simple cases mod_alias is easier to use.
> 
> 1 - https://httpd.apache.org/docs/current/mod/mod_alias.html
> 2 - https://httpd.apache.org/docs/current/mod/mod_rewrite.html
> 
> On 26/06/2017 14:29, Daniel wrote:
>> Note the first one (the redirect) will probably redirect incorrectly,
>> target should end with a trailing slash.
>>
>> Golden rule: if souce ends in trailing slash, target must also end in
>> trailing slash.
>>
>> 2017-06-26 21:23 GMT+02:00 Eric Covener <covener@gmail.com>:
>>> On Mon, Jun 26, 2017 at 3:16 PM, David Mehler <dave.mehler@gmail.com> 
>>> wrote:
>>>> I'm using apache 2.4. What is the difference between these lines?
>>>>
>>>> Redirect permanent / http://www.domain.com
>>>>      RewriteRule ^/?(.*) http://www.domain.com/$1 [R,L]
>>>
>>> Nothing really, when you add the 'R' flag you're asking mod_rewrite to
>>> redirect instead of performing an internal rewrite of the URL or file
>>> path.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>
>>
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message