Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-25-2013, 03:45 PM   PM User | #1
Coastal Web
Regular Coder

 
Coastal Web's Avatar
 
Join Date: Oct 2004
Posts: 225
Thanks: 12
Thanked 3 Times in 3 Posts
Coastal Web is an unknown quantity at this point
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?

Code:
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?
Code:
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!
Coastal Web is offline   Reply With Quote
Old 02-25-2013, 10:42 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Not sure about the redirect since I don't think I've ever used it. But I'd expect rewrite would do it:
Code:
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Tags
301, htaccess, redirect

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:37 PM.


Advertisement
Log in to turn off these ads.