Results 1 to 7 of 7
  1. #1
    Doolally's Avatar
    Doolally is offline Private Member
    Join Date
    February 2003
    Location
    Scotland
    Posts
    4,584
    Thanks
    501
    Thanked 732 Times in 572 Posts

    Default 301 Redirect Question

    Can anyone explain how to redirect all files in a certain directory to a single, alternative page, using 301 Redirect?

    I was to delete a section of a site of mine and make all visitors trying to access any of those pages, currently within a certain directory, redirect to a different landing page.

  2. #2
    dfiocch's Avatar
    dfiocch is offline Private Member
    Join Date
    September 2006
    Posts
    876
    Thanks
    787
    Thanked 565 Times in 348 Posts

    Default

    You can do it through your .htaccess file.

    First of all, make sure your Rewrite engine is set to on:

    Code:
    RewriteEngine on
    Then, after this line, you can do:

    Code:
    RewriteRule ^sectiontobemoved/ /landig-page.html [R=301,L]

  3. The Following 2 Users Say Thank You to dfiocch For This Useful Post:

    Doolally (13 February 2016), TheGooner (13 February 2016)

  4. #3
    Doolally's Avatar
    Doolally is offline Private Member
    Join Date
    February 2003
    Location
    Scotland
    Posts
    4,584
    Thanks
    501
    Thanked 732 Times in 572 Posts

    Default

    Thanks!!

    Didn't quite work for me but sent me in the right direction. The code that actually worked for me was:

    ReWriteRule ^sectiontobemoved/.*$ /landingpage.html [R=301,L]


  5. The Following User Says Thank You to Doolally For This Useful Post:

    TheGooner (13 February 2016)

  6. #4
    dfiocch's Avatar
    dfiocch is offline Private Member
    Join Date
    September 2006
    Posts
    876
    Thanks
    787
    Thanked 565 Times in 348 Posts

    Default

    My fault, sorry. Forgot the ".*$" 'wildcard'.
    In some cases (as yours) you need to specify "also files contained in", so ".*$".

    I'm glad it works

  7. The Following User Says Thank You to dfiocch For This Useful Post:

    Doolally (14 February 2016)

  8. #5
    TheGooner's Avatar
    TheGooner is offline Private Member
    Join Date
    March 2007
    Location
    New Zealand
    Posts
    4,571
    Thanks
    2,093
    Thanked 4,541 Times in 2,181 Posts

    Default

    Thanks for the discussion guys - that saved me a couple of hours research later on today
    Much appreciated

  9. The Following User Says Thank You to TheGooner For This Useful Post:

    dfiocch (13 February 2016)

  10. #6
    mickekneg's Avatar
    mickekneg is offline Private Member
    Join Date
    November 2015
    Location
    Malta
    Posts
    58
    Thanks
    3
    Thanked 17 Times in 12 Posts

    Default

    If you are running wordpress, there are plugins for 301 redirects that are fairly easy to use as well.

    Regards

  11. #7
    universal4's Avatar
    universal4 is offline Forum Administrator
    Join Date
    July 2003
    Location
    Courage is being scared to death...and saddling up anyway. John Wayne
    Posts
    34,126
    Thanks
    4,580
    Thanked 9,336 Times in 6,012 Posts

    Default

    Using a plugin to do redirects that can be much faster in htaccess adds more overhead than necessary.

    Rick
    Universal4

Tags for this Thread

Posting Permissions

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