Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder Coastal Web's Avatar
    Join Date
    Oct 2004
    Thanked 3 Times in 3 Posts

    301 redirect many files to one?

    Hi guys, l'm trying to use htaccess to 301 redirect a bunch of old pages to a newly improved page. -- l have a lot of them and l was wondering if there was a cleaner way of doing this?

    Redirect 301 /page1/ /newpage/
    Redirect 301 /page1 /newpage/
    Redirect 301 /page2/ /newpage/
    Redirect 301 /page2 /newpage/
    Redirect 301 /page3/ /newpage/
    Redirect 301 /page3 /newpage/
    Is there something like this l can do?
    Redirect 301 (/page3|/page2|page1) /newpage/
    Another point to mention, l have each URL listed twice, because it doesn't seem to work because of the trailing slash on the old page -- sometimes it's there for visitors sometimes it's not.
    Need a way to drive traffic to your new site?
    ==> Check out HelpMyHits.com!

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,668 Times in 2,637 Posts
    Not sure about the redirect since I don't think I've ever used it. But I'd expect rewrite would do it:
    RewriteRule ^/page([0-9]+)/?$ newpage/ [L,QSA,R=301]
    Something like that maybe (untested, don't know if it'll work)? Only really useful if the pages are actually named pagex where x is any number.
    Otherwise, nothing stops you from using the | separator in the rule pattern to specify the individual pages.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


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