Forum Moderators: phranque

Message Too Old, No Replies

Redirect page## to page0##

using RedirectMatch

         

milanmk

1:07 pm on Mar 31, 2006 (gmt 0)

10+ Year Member



I want to redirect all the request for page##.htm to page0##.htm using RedirectMatch 301.

I tried the following but did not worked.

RedirectMatch 301 /page(\d{2}).htm http://example.com/page0$1.htm

Any suggestions?

[edited by: jdMorgan at 3:19 am (utc) on April 1, 2006]
[edit reason] Example.com [/edit]

moltar

2:09 pm on Mar 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You were close to the truth :) You need to use mod_rewrite for this.

RewriteEngine On 
RewriteRule /page(\d{2})\.htm http://%{HTTP_HOST}/page0$1.htm [R=301,L]

[edited by: jdMorgan at 3:14 am (utc) on April 1, 2006]
[edit reason] Formatting [/edit]

milanmk

3:03 pm on Mar 31, 2006 (gmt 0)

10+ Year Member



moltar, I tried that but still not working.

Any more suggestions?

jdMorgan

3:18 am on Apr 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RedirectMatch should work fine for this applicaton.

Try this:


RedirectMatch 301 ^/page([0-9]{2})\.htm$ http://example.com/page0$1.htm

If it fails, please post the URL-path you entered in your browser, and the result. "It doesn't work" gives us no information to help you with. Relevant entries from your server access and error logs might be quite helpful.

Also be aware that you should flush your browser cache before testing any change to your URL system.

Jim

milanmk

6:39 am on Apr 1, 2006 (gmt 0)

10+ Year Member



What i really mean by "It doesn't work" was the reg exp was not matching page##.htm and therefore it was giving 404 error for page request "page09.htm".

But i tried your solution and its working great, thank you Jim.

I was wondering why "page(\d{2})\.htm" reg exp did not worked!