homepage Welcome to WebmasterWorld Guest from 54.227.40.166
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
What is the best method of redirecting deprecated pages?
Apache/ Linux
stuntdubl




msg:1516472
 6:52 pm on Aug 14, 2003 (gmt 0)

I have a new site that is going live at the end of this month.

The old structure was terrible and I decided despite reasonable amounts of SE traffic that it will be more worthwhile to scrap the old url's and start from scratch.

Anyhow....I have one set of about 10 pages that does well for "event widgets" term....or "pictures of event widgets".

When the new site goes up there will only be one page (for a little while), and I will be rebuilding the set of pages at a later time.

I digress.....
I know that there are a couple ways to do redirects.....what would be the best for this situation, and can you point me in the direction of a tutorial?

[mydomain.com...]
[mydomain.com...]
[mydomain.com...] etc.
will point to
[mydomain.com...]

 

wkitty42




msg:1516473
 8:44 pm on Aug 14, 2003 (gmt 0)

i'd look into mod_rewrite for this one... if the samples you gave are representative of the actual ones you're moving, something like this may do it for you...

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_URI} ^/event-widgets\.htm$ [OR]
RewriteCond %{REQUEST_URI} ^/event-widgets([0-9]¦[1-9][0-9])\.htm$
RewriteRule .* http://www.mydomain.com/event-widgets/event-widgets.htm [R=301,F]

those regexps are the trick... i'm sure that the two conditions could be combined into one but wasn't able to figure it out "on the fly"...

if i've got it right, it says that /event-widgets.htm is to be redirected and /event-widgets0 thru 99.htm are to be redirected... i used a 301 code for a permanent redirect...

the numerical regexp allows 0-9 or 10-99... if you actually have 00, 01, 02, 03, then using [0-9][0-9] instead of (blah¦blahblah) will cover all two character numericals...

if you have three character numericals, you should easily see the method to include 100-999 ;)

please note that you'll have to use the real verticle bar (aka pipe) if you cut and paste this... the board alters the pipe to a solid one instead of the broken one...

[edit: cleaned up code mistakes]

wkitty42




msg:1516474
 2:50 pm on Aug 15, 2003 (gmt 0)

arrrgh!

that last line should end in [R=301,L]

L for Last not F :(

[the edit button's gone away so i can't edit it right in the message]

stuntdubl




msg:1516475
 3:43 pm on Aug 15, 2003 (gmt 0)

Thank you for the suggestions.

I am not very knowledgeable of my webserver....where would I place this code?

In the .htaccess file of the root webserver directory?

I have other pages that would be nice to redirect as well....If I have 20 or 30 redirects is that going to slow the site down quite a bit?

I have about 6 other "mainpages" that would be nice to do permanent redirects on also, but not at the expense of performance.

wkitty42




msg:1516476
 4:21 pm on Aug 15, 2003 (gmt 0)

yes, the ones i showed are for the .htaccess file... they should work if your server is apache oriented and is configured for .htaccess use...

there should not be any noticible difference in speed... not unless you get something goofed and toss the server into a rewrite loop... i've done that a time or two and was glad i had access to the server to stop the apache process and restart it...

you shouldn't have any problems rewritting and redirecting many pages... i'd list each group in a block that's commented as to what it is for... then, you can watch the logs for when those redirected pages aren't being called any more and trim that code out after a while...

the two or three lines at the top of the example i showed you are only needed in the file once...

if the site listed in your profile is the one you are working on, it is an apache server (i peeked at the headers ;)) very nice site and topic... excellent job...

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved