301 files and folder redirect

New to mod_rewrite? This is a good place to start.

301 files and folder redirect

Postby hydroplane » Thu Aug 13, 2009 7:58 am

Hi!
hope someone here can help. I moved the content of one folder into another. I need to set a permanent redirect for the old folder and its files to the new addresses. Here's what the urls look like. Thanks a lot in advance!

Code: Select all
http://site.com/photos/Miscellaneous/John Doe/

To
Code: Select all
http://site.com/photos/Scans/abc magazine (Summer 2009)/




Code: Select all
http://site.com/photos/Miscellaneous/John Doe/001.jpg.php
[...] files are always named 002, 003, 004 and so on till 012
http://site.com/photos/Miscellaneous/John Doe/012.jpg.php

To
Code: Select all
http://site.com/photos/Scans/abc magazine (Summer 2009)/usd-magazine-001.jpg.php
[...]
http://site.com/photos/Scans/abc magazine (Summer 2009)/usd-magazine-012.jpg.php




Code: Select all
http://site.com/photos/Miscellaneous/John Doe/001.jpg.php?z&p=full-image
[...]
http://site.com/photos/Miscellaneous/John Doe/012.jpg.php?z&p=full-image

To
Code: Select all
http://site.com/photos/Scans/abc magazine (Summer 2009)/usd-magazine-001.jpg.php?z&p=full-image
...
http://site.com/photos/Scans/abc magazine (Summer 2009)/usd-magazine-012.jpg.php?z&p=full-image
hydroplane
 
Posts: 1
Joined: Thu Aug 13, 2009 7:23 am

Postby richardk » Fri Aug 14, 2009 1:23 pm

What should happen to numbers other than 001 to 012?

Try (mod_alias)
Code: Select all
RedirectMatch 301 ^/photos/Miscellaneous/John\ Doe/?$ http://www.example.com/photos/Scans/abc\ magazine\ (Summer\ 2009)/
RedirectMatch 301 ^/photos/Miscellaneous/John\ Doe/(0(0[1-9]|1[012])\.jpg\.php)$ http://www.example.com/photos/Scans/abc\ magazine\ (Summer\ 2009)/$1
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 33 guests

cron