Results 1 to 4 of 4

Thread: 301 Redirect .htaccess question

  1. #1
    Senior Member Andaho's Avatar
    Join Date
    Jul 2007
    Posts
    591
    Thanks
    241
    Thanked
    8 times in 8 posts
    • Andaho's system
      • Motherboard:
      • ASUS iX2 GTXS
      • CPU:
      • XC18650 4.2GHz 10664FSB 16 Core
      • Memory:
      • 64GB (2x32GB sticks) PC21320 Corsair Domititan Magnetic RAM 0 latency
      • Storage:
      • 16TB Western Digital SATAV 28800RPM Ultra Edition 1GB Cache
      • Graphics card(s):
      • XFX AMD 9985GTS LP 25Watt
      • PSU:
      • 150W Corsair
      • Case:
      • Lian-Li Aluminium ABX-951
      • Monitor(s):
      • SG-942IPS 42" 3840x2160 0.01ms 5,000,000,000:1
      • Internet:
      • 10Gb Virgin Media Cable

    Lightbulb 301 Redirect .htaccess question

    In the .htaccess file, what is the difference between using:

    Code:
    RewriteEngine On
    RewriteRule ^(.*)$ http://www.google.com [R=301,L]
    or

    Code:
    Redirect 301 / http://www.google.com
    What are the benefits of using one over the other?

    Many thanks.

  2. #2
    Senior Member
    Join Date
    Aug 2013
    Location
    North Wales
    Posts
    1,849
    Thanks
    165
    Thanked
    271 times in 202 posts
    • virtuo's system
      • Motherboard:
      • Gigabyte Aorus Master X570
      • CPU:
      • Ryzen 9 5950x
      • Memory:
      • 64Gb G.Skill TridentZ Neo 3600 CL16
      • Storage:
      • Sabrent 2TB PCIE4 NVME + NAS upon NAS upon NAS
      • Graphics card(s):
      • RTX 3090 FE
      • PSU:
      • Corsair HX850 80+ Platinum
      • Case:
      • Fractal Meshify 2 Grey
      • Operating System:
      • RedStar 3, Ubuntu, Win 10
      • Monitor(s):
      • Samsung CRG90 5140x1440 120hz
      • Internet:
      • PlusNet's best, but still poor, attempt

    Re: 301 Redirect .htaccess question

    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.

  3. Received thanks from:

    Andaho (06-03-2014)

  4. #3
    Senior Member Andaho's Avatar
    Join Date
    Jul 2007
    Posts
    591
    Thanks
    241
    Thanked
    8 times in 8 posts
    • Andaho's system
      • Motherboard:
      • ASUS iX2 GTXS
      • CPU:
      • XC18650 4.2GHz 10664FSB 16 Core
      • Memory:
      • 64GB (2x32GB sticks) PC21320 Corsair Domititan Magnetic RAM 0 latency
      • Storage:
      • 16TB Western Digital SATAV 28800RPM Ultra Edition 1GB Cache
      • Graphics card(s):
      • XFX AMD 9985GTS LP 25Watt
      • PSU:
      • 150W Corsair
      • Case:
      • Lian-Li Aluminium ABX-951
      • Monitor(s):
      • SG-942IPS 42" 3840x2160 0.01ms 5,000,000,000:1
      • Internet:
      • 10Gb Virgin Media Cable

    Re: 301 Redirect .htaccess question

    Quote Originally Posted by virtuo View Post
    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.
    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?

  5. #4
    Senior Member
    Join Date
    Aug 2013
    Location
    North Wales
    Posts
    1,849
    Thanks
    165
    Thanked
    271 times in 202 posts
    • virtuo's system
      • Motherboard:
      • Gigabyte Aorus Master X570
      • CPU:
      • Ryzen 9 5950x
      • Memory:
      • 64Gb G.Skill TridentZ Neo 3600 CL16
      • Storage:
      • Sabrent 2TB PCIE4 NVME + NAS upon NAS upon NAS
      • Graphics card(s):
      • RTX 3090 FE
      • PSU:
      • Corsair HX850 80+ Platinum
      • Case:
      • Fractal Meshify 2 Grey
      • Operating System:
      • RedStar 3, Ubuntu, Win 10
      • Monitor(s):
      • Samsung CRG90 5140x1440 120hz
      • Internet:
      • PlusNet's best, but still poor, attempt

    Re: 301 Redirect .htaccess question

    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&param3=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.

  6. Received thanks from:

    Andaho (06-03-2014)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •