Forum Moderators: phranque

Message Too Old, No Replies

wildcard for redirecting similar files to one page

         

samclam

10:25 pm on Aug 14, 2010 (gmt 0)

10+ Year Member



I have multiple obsolete pages (individual pages with one photo each) in the root. I want requests for all these pages to be redirected to one new page.

The old pages are individual photos. The new page is a wordpress photo gallery.

The old pages are named, for example:
h*tp://www.mysite.com/oldpage01.htm
h*tp://www.mysite.com/oldpage02.htm

The new page is:
h*tp://www.mysite.com/photo gallery/

Question 1: Is this correct:
Redirect 301 oldpage01.htm h*tp://www.mysite.com/photo gallery/

Question 2: Is there a wild card for the "oldpage" suffixes (i.e. 01, 02, 03, etc.)?

Thank you for any help.

jdMorgan

1:21 pm on Aug 15, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please define "oldpage suffixes" more precisely. What is the maximum possible range of these suffixes? Are leading zeros always used? Can these suffixes contain letters? -- And if so, are they lowercase, uppercase, or mixed-case?

The Redirect directive cannot use wild-cards in the middle of the URL-path, but mod_access RedirectMatch and mod_rewrite RewriteRule use regular-expressions to support wild-cards. An example regular expression for URL-paths /oldpage00.html through /oldpage99.htm would be ^oldpage[0-9]{2}\.htm$

See the Regular-expressions tutorials cited in our Forum Charter and in our Apache Forum Library.

Jim

samclam

12:24 am on Aug 16, 2010 (gmt 0)

10+ Year Member



Thanks. I've spent days going through the tutorials and library; some of it I understand, but most is over my head...

If you have the time, I have another question, I can't find an answer to:

There are many dozens of obsolete old .htm pages I want to redirect to a wordpress rebuild of our site.

So, I have many pages like:

h*tp://www.mysite.com/cat.htm
h*tp://www.mysite.com/dog.htm
h*tp://www.mysite.com/birds/crow.htm
etc.

It's not well-organized; we're trying to clean it up.

Is there way to use RewriteRule so that ALL pages ending in .htm are redirected to

h*tp://www.mysite.com/animals/

or, if that isn't feasible, to just:

h*tp://www.mysite.com/

Thanks.

jdMorgan

1:56 am on Aug 19, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




RewriteRule \.htm$ http://www.example.com/animals/? [R=301,L]
-or-
RedirectMatch 301 \.htm$ http://www.example.com/animals/?

I strongly suggest that you use the former (RewriteRule) if you currently use or ever wish to use other mod_rewrite rules.

Jim

samclam

2:24 am on Aug 19, 2010 (gmt 0)

10+ Year Member



Thank you, I appreciate it. I will try that, the former that is.