In the .htaccess file, what is the difference between using:
orCode:RewriteEngine On RewriteRule ^(.*)$ http://www.google.com [R=301,L]
What are the benefits of using one over the other?Code:Redirect 301 / http://www.google.com
Many thanks.
In the .htaccess file, what is the difference between using:
orCode:RewriteEngine On RewriteRule ^(.*)$ http://www.google.com [R=301,L]
What are the benefits of using one over the other?Code:Redirect 301 / http://www.google.com
Many thanks.
The first one requires mod_rewrite to be enabled on your Apache server, which not everyone has (or wants). The second one uses mod_alias, which is essentially a stripped down version of mod_rewrite. It's not as powerful, but for basic redirects such as your example, would be sufficient.
Performance-wise there's not much in it, but I'd say if you have mod_rewrite available, use that.
Andaho (06-03-2014)
Thanks very much for your reply...
That's pretty much what I've read from googling the question...
But what I don't understand, that I've seen written other places too, is "It's not as powerful"?
I've seen other conflicting advice stating: "mod_rewrite should be considered a last resort, when other alternatives are not available" - but they don't go on to explain why :S
My host instructions use mod_rewrite: http://www.youtube.com/watch?v=pCJBp8yDpE8
On that video you can see I asked the question there too.
I guess it's something I don't really need to know... it's just bugging me that I can't find a proper explanation... Yes it's only a basic redirect I'm doing, forwarding a .com to .co.uk... And I started looking into it because I want to do it the most SEO friendly way.... but I'm guessing any 301 redirect is equally SEO friendly?
Well mod_rewrite is used to rewrite your requests/queries, so basically you could map http://url.com/1/3 to http://url.com/?param1=1¶m3=3. It can get very complex.
The mod_alias "Rewrite" functionality doesn't have the ability to manipulate requests/parameters in that way and will simply rewrite an url to another url using a 30x redirect without doing anything useful with the rest of the request. In that respect it's far less powerful. It can do other things, but I don't use it. Apparently you can squeeze it to work a bit like mod_rewrite, but it seems more hassle.
I disagree that mod_rewrite should be a last resort. It has its pitfalls but it's extremely powerful.
301 and 302 should be used as appropriate (301 moved permanently, 302 moved temporarily). In your case 301 seems correct. I think the general consensus in terms of SEO is to use 301, but again you'll find conflicting arguments.
Andaho (06-03-2014)
There are currently 1 users browsing this thread. (0 members and 1 guests)