Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- 301'ing over 50 thousand pages


g1smd - 2:46 pm on Mar 9, 2011 (gmt 0)


Each of the ( ) pairs is "capturing" a part of the requested old URL when a user continues to request the old URL from their bookmarks or in an old email or stale SERP.

Each captured part of the sliced up URL is stored as a variable, starting at $1 for the first. Those variables are then substituted when you "make" the new URL that you want the user to be redirected to. The redirect forces the user to make a new request for that new URL, whenever they request the old one.

In that example, I "re-used" only the $6, $2 and $3 parts of the original URL, to make the redirect to the new URL.


Given the old and new URL format example shown in your second post, you should be able to similarly slice up the old URL and grabs bits of it to make the string for the new URL.

It might help to know that
[^/] means "NOT a slash", and the plus means "one or more times", so ([^/]+)/ matches everything up to the first slash and puts it in $1. You have both the slash and underscore separators in the old URL to help with the pattern matching.


Thread source:: http://www.webmasterworld.com/apache/4278367.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com