Forum Moderators: phranque

Message Too Old, No Replies

Mod rewrite syntax question

Having trouble with this url

         

etali

1:32 pm on Jun 11, 2005 (gmt 0)

10+ Year Member



Hi

I'm pretty new at this sort of thing, I've been using mod_rewrite for really simple changes to URLs in the past, but I've been asked to convert an older site that runs from pure HTML to something easier to update.

I was planning on keeping their basic structure, and doing the database stuff around it.

Their URLS currently look like this:

TOPICreviewFIRSTLETTER.html

I was hoping to make a rewrite rule that would convert it over to

review.php?subject=TOPIC&letter=A (for example)

RewriteRule (.*)review(.*)\.html$ /reviews.php?subject=$1&letter=$2

This is causing a server error when I try it.

I am completely new to this, so if I'm way off with my syntax then please don't laugh too much!

Any advice appreciated.

Dapuzz

1:40 pm on Jun 11, 2005 (gmt 0)

10+ Year Member



Your code on my server does not give me any error.
You can try whith this:
RewriteEngine on
RewriteRule ^(.*)review(.)\.html$ /reviews.php?subject=$1&letter=$2 [R,L]
Remove the [R] when you are shure that it is working.

etali

2:01 pm on Jun 11, 2005 (gmt 0)

10+ Year Member



Thanks for checking so quickly!

I think I found the problem, the links to the reviews themselves are re-written from a similar file name:

RewriteRule review(.*)\.htm$ /review.php?newsid=$1

If I remove that rewrite then the other one works, put it back in and neither work.

Is it possible to have both re-writes working? Or will I have to change he file name on one of them so that there isn't a conflict?

Thanks again.

Dapuzz

2:15 pm on Jun 11, 2005 (gmt 0)

10+ Year Member



you can use the [L] "last" flag to the rule so if the pattern is matched no other rules will be followed.
You can use ^(.+)review(.)\.html$ to match all the pages that have "one or more" letters before review and "only one" letters after to solve your problem

etali

2:22 pm on Jun 11, 2005 (gmt 0)

10+ Year Member



That worked a treat, thanks!