Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite doubt

moving from php-nuke to phpbb

         

raul2010

12:58 pm on Feb 5, 2006 (gmt 0)

10+ Year Member



Hi

I recently moved a php-nuke forum to a plain phpbb one, and as expected all topics URLs have changed:

from: www.mydomain.com/modules.php?name=Forums&file=viewtopic&t=1
to: www.mydomain.com/viewtopic.php?t=1

what I wanted to do now was catching all old URLs and redirecting them to the new ones.
I've reading documentation here:
[webmasterworld.com...]
[webmasterworld.com...]

so I wrote this in my .htaccess:

RewriteEngine On
Options +FollowSymlinks
RewriteRule ^modules\.php\?name=Forums&file=viewtopic&(.*) /forum/viewtopic.php?$1 [R=301,L]

but this is not working at all. I suppose I have some stupid (or really huge) mistake in the rule but sincerely I don't know what to try.

Any ideas?

Birdman

3:18 pm on Feb 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll need to use rewritecond to get at the query string. The rules below should do what you need. Notice the backreferenced variable uses %1, rather than $1.

RewriteEngine On
Options +FollowSymlinks
rewritecond %{QUERY_STRING} ^name=Forums&file=viewtopic&(.*)$
RewriteRule ^modules\.php? /forum/viewtopic.php?%1 [R=301,L]

raul2010

4:04 pm on Feb 5, 2006 (gmt 0)

10+ Year Member



Thank you very much!

It's working now, and also I think I understand mod_rewrite a little better.

Birdman

9:28 pm on Feb 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You are very welcome. Definately check the WW Apache Library, for alot of good info:

[webmasterworld.com...]